Pass arguments from csh to the program, just like they

I have a csh script that runs using "source" and passes all of its arguments to the program:

% alias foo source foo.csh % cat foo.csh ./bar $* # Some uninteresting stuff 

If I run source foo.csh abc , everything is fine. But not always:

  1. foo "ab" "cd" :
    I expect bar receive two arguments - ab and cd . Instead, he gets 4.

  2. foo a "*" b : * expands to a list of files. I just want a character * .
    Extra credit - foo a * b should work the same way. I know this is more problematic, and I want to live without it.

One thing I tried is changing ./bar $* to ./bar "$*" . This helps with an asterisk, but now bar always gets everything in one parameter.

Notes:

  1. Our company uses csh as a login shell, so I have to use it when using source . Knowing that csh programming is considered harmful , I implemented all the logic in bar and left a minimum in the script.

  2. If you suggest overriding the alias, it is important to make sure that the redirection still works ( foo | grep hello ) and that ctrl-C crashes the script.

+9
linux csh
source share
1 answer

Meanwhile, I myself found the answer:

./bar $argv:q

Modifier :q takes care of things. It goes to bar , getting the exact parameters of foo .

Source: http://www.staff.tugraz.at/reinfried.o.peter/unix/cshell.html

+18
source share

All Articles