[cs631apue] Question about -c option
Jan Schaumann
jschauma at stevens.edu
Thu Dec 10 22:52:16 EST 2015
gcheng2 <gcheng2 at stevens.edu> wrote:
> Is -c option only for commands without options?
No, you can pass any command or sequence of commands via the "-c".
For example:
sish -c "ls"
sish -c "ls >out"
sish -c "ls | wc -l"
In this regard your shell is no different from, say, bash:
bash -c "ls"
bash -c "ls >out"
bash -c "ls | wc -l"
> How do we handle
> commands like
> sish -c "echo $?"
>
> $? will be auto transferred to a number(exit status of previous
> command), we could not read the string "$?".
That is because your current shell interpretes $?. Use single quotes to
avoid interpretation of $:
sish -c 'echo $?'
(Although that is not a useful command, since there is no previous
command from which to get the exit status.)
-Jan
More information about the cs631apue
mailing list