Shell Commands and Program Arguments
A shell interprets a command line and starts a program with an argument list. The program receives the resulting values.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a name with spaces
A filename such as weekly report.csv must reach a reader as one argument. Quoting can tell the shell where that argument ends. See command arguments as text for what the program receives.
Check where options are interpreted
The shell organizes arguments and can perform expansions. The command itself interprets option names and values. Program input boundaries distinguish that application rule from the preceding invocation.[1]
Inspect the argument vector after the shell evaluates the line
A toy converter receives a filename and a format option. Writing the filename in quotes lets one argument contain a space. The program sees the filename without the grouping quotes under ordinary shell parsing. See a structured argument list for calling it through an API.
Typed: convert "field notes.txt" --format csv
Program arguments: ["field notes.txt", "--format", "csv"]
Omitting the quotes can produce separate field and notes.txt arguments
Make an argument echo fixture before testing special names
A fixture program can print each received argument separately. Try an empty argument, a name containing a space, and one containing literal quote characters. This distinguishes shell interpretation from the converter's option handling.