Launching a Program with a Structured Argument List

A process launcher can often receive an executable and separate argument values directly. This avoids depending on shell interpretation for ordinary paths and settings.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a filename with spaces
  2. Test the actual receiver
  3. Pass a filename as one value through the process API
  4. Keep shell expansion deliberate

Trace a filename with spaces

A caller supplies one argument holding weekly report.csv. The receiver should see that exact value as one argument according to the launcher API. See shell argument formation for the separate command-line parsing step.

Test the actual receiver

A benign test command can print argument counts and their reversible representations. Check spaces, empty strings, and punctuation according to the platform contract. Text representations make an empty argument distinguishable from no argument.[1]

Pass a filename as one value through the process API

A converter can be launched with separate entries for the executable, a file name containing a space, and an option. The process adapter can preserve these boundaries without a shell interpreting metacharacters. See shell commands and arguments.

Entry 0: converter executable
Entry 1: blue notes.txt
Entry 2: --summary
Expect the program to see two argument values after its invocation name under the model

Keep shell expansion deliberate

A structured invocation does not normally perform glob expansion or pipeline syntax. If the application needs multiple paths, enumerate them intentionally and pass their exact values. Test an empty argument and a name containing a space.

References

  1. The Open Group, POSIX Shell Command Language ↩