In Unix (tcsh), I've referenced command line arguments in my aliases with two different notations - $1
and \!:1
.
But I noticed that if I try to save $1
to an environment variable, it doesn't get saved. However \!:1
does get saved.
alias hear 'setenv x \!:1 && echo $x'
--> hear that
that
--> echo $x
that
alias oh 'setenv x $1 && echo $x'
--> oh no
no
--> echo $x
Nothing shows up on the echo of $x when $1 is used to store the value. What is the reason for this?
$1
returns the first argument passed to the script that contains the alias
command. So if you are calling it from the command line, it will return nothing.
\!:1
returns the first argument passed to the aliased command, so that is clearly what you should be using.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With