Shuman
Shuman

Reputation: 4132

How to get the second argument till the last one in csh?

I want to make an alias for the rbt command. I thought it should be:

alias myrbt 'rbt \!:1 --server=myserver --repository-url=myurl \!:2- \!:$'

the expected result is when I run

myrbt diff 12345

it should run

rbt diff --server=myserver --repository-url=myurl 12345

when I run

myrbt post 1.py 2.py

it should run

rbt post --server=myserver --repository-url=myurl 1.py 2.py

...but it doesn't work.

Upvotes: 0

Views: 132

Answers (1)

Martin Tournoij
Martin Tournoij

Reputation: 27852

I think this is what you're looking for?

# Replace `echo` with `rbt`
$ alias myrbt 'echo \!:1 --server=myserver --repository-url=myurl \!:2*'

$ myrbt diff 12345
post --server=myserver --repository-url=myurl 12345

$ myrbt post 1.py 2.py
post --server=myserver --repository-url=myurl 1.py 2.py

The reason your version doesn't work is that with \!:2- doesn't seem to work if there are only two parameters (there need to be at least three).

Upvotes: 1

Related Questions