Thread: NP_Arguments
View Single Post
Old 25 January 2023, 17:17   #4
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,233
Quote:
Originally Posted by Wepl View Post
Autodocs for SystemTagList tell:
Yes, those are the tags that are actively filtered out, but that does not mean that all the other tags are functional. Just remember what System() does: It runs into CreateNewProc(), starting a new process, but the seglist of this process is the (specified, user or system) shell. The shell segment does not expect arguments in a0/d0 and the input file handle as usual command line tools do, it simply does not care about them. Rather, the shell uses a somewhat awkward (and as of 3.2, a little bit less bit still awkward) startup message to receive its intstructions, and this message reflects (to some degree) the arguments to Sytem().



Even then, what should the shell do with arguments that are not really meant for its own process, but for a script that still needs to be loaded? These are not arguments that should go to the shell, but rather to its first (or all?) commands to load.



Instead, the command or script to be executed, along with its full arguments, quoted according to the shell syntax, need to be provided as string as first argument to System(). This string is then "magically" converted to a command stream that is interpreted (applying all the wierd syntax rules) of the shell.


Thus, if you have any arguments to pass, make sure you quote them correctly, and escape quotes within quoted strings correctly, and so on.

Quote:
Originally Posted by Wepl View Post
Anyhow, I think I will concatenate the args to the command and avoid NP_Arguments.
This is almost, but not entirely correct. Consider the four arguments


foo
bl"a
hi there
wh*at no"w


then concatenation will not give the right result. You need to quote anything that contains blanks, and escape any special character, but only those that got quoted. Thus:


foo bl"a "hi there" "wh**at no*"w"


would be correct. Getting these things straight can be medium nightmare as the quotation rules of the shell are rather "bizarre".
Thomas Richter is offline  
 
Page generated in 0.04931 seconds with 11 queries