mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:12:44 +00:00 
			
		
		
		
	Shell: Add a 'glob' builtin
This builtin takes a bunch of strings, resolves them as globs (in the current directory) and prints out the matching entries. Its main use is to allow dynamic glob resolution: ```sh glob "$whatever/*" ```
This commit is contained in:
		
							parent
							
								
									af28a8ad11
								
							
						
					
					
						commit
						97c5a78d27
					
				
					 2 changed files with 18 additions and 0 deletions
				
			
		|  | @ -327,6 +327,23 @@ int Shell::builtin_export(int argc, const char** argv) | |||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| int Shell::builtin_glob(int argc, const char** argv) | ||||
| { | ||||
|     Vector<const char*> globs; | ||||
|     Core::ArgsParser parser; | ||||
|     parser.add_positional_argument(globs, "Globs to resolve", "glob"); | ||||
| 
 | ||||
|     if (!parser.parse(argc, const_cast<char**>(argv), false)) | ||||
|         return 1; | ||||
| 
 | ||||
|     for (auto& glob : globs) { | ||||
|         for (auto& expanded : expand_globs(glob, cwd)) | ||||
|             outln("{}", expanded); | ||||
|     } | ||||
| 
 | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| int Shell::builtin_fg(int argc, const char** argv) | ||||
| { | ||||
|     int job_id = -1; | ||||
|  |  | |||
|  | @ -47,6 +47,7 @@ | |||
|     __ENUMERATE_SHELL_BUILTIN(pwd)     \ | ||||
|     __ENUMERATE_SHELL_BUILTIN(exit)    \ | ||||
|     __ENUMERATE_SHELL_BUILTIN(export)  \ | ||||
|     __ENUMERATE_SHELL_BUILTIN(glob)    \ | ||||
|     __ENUMERATE_SHELL_BUILTIN(unset)   \ | ||||
|     __ENUMERATE_SHELL_BUILTIN(history) \ | ||||
|     __ENUMERATE_SHELL_BUILTIN(umask)   \ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 AnotherTest
						AnotherTest