Variadic Positional Arguments Create Parsing Ambiguity #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The manifest schema allows defining arrays for positional arguments (e.g.,
array[path]). However, when an array is followed by another positional argument, the shell's parser will fundamentally struggle to determine where the variadic array ends and the next discrete argument begins.For devs:
The
copycommand specifies two positional arguments in its manifest:sourceof typearray[path], followed immediately bydestinationof typepath.If a user types
copy file1.txt file2.txt file3.txt, how does the shell's AST parser logically determine whetherfile3.txtis the third item in thesourcearray, or if it represents the singulardestinationargument? In legacy Unix,cphandles this ambiguity internally at runtime by checking the filesystem to see if the last argument is an existing directory. But in ZerOS, the shell is explicitly responsible for validating types ahead of time using the manifest. If the shell's parser greedily consumes paths into thearray[path], it will exhaust the input and never populate the requireddestinationargument.For users:
Users expect predictable parsing. If the shell tries to guess the boundary of the array based on runtime filesystem state, it breaks the promise of predictable, offline syntax validation.
Test Examples
copy a.txt b.txt c.txt(Parsing ambiguity: isc.txtpart of the source array or the destination?)move folder1/ folder2/ archive/(Same variadic ambiguity)Since ZerOS explicitly rejects legacy Unix conventions for the sake of usability and correctness, we have the freedom to propose a clean, non-ambiguous solution. This might involve explicit syntax for array termination, or simply reconsidering how variadic commands are structured so they don't clash with subsequent positional arguments.