You are not logged in.
case "$1" in
install|-i)
PKG="$@"
install_package ;;
remove|-r)
PKG="$@"
remove_package ;;
esac
Problem is that -i (or -r) are picked as part of $PKG variable and I can't find solution for PKG to be $2 $3... and anything after that (not $1, because it is taken).
I hope you could understand this.
Last edited by simargl (2013-03-14 16:19:09)
Offline
I, for one, cannot understand. Please clearly explain what you're trying to accomplish, show us example input and ouput, etc.
As a minor rant, not to be taken personally, it's really frustrating to me when a thread opens with a code/output example with no text introducing what I'm supposed to be looking at in the example. Please provide at least a small introduction so people know what you're talking about; we can't all read minds here.
Offline
Have a look at getopts. It's in man Bash and a web search will pull up many examples.
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
Are you looking for
shift
?
Offline
Thanks for your comments,
What I want is for example type:
spkg -i NAME1 NAME2 NAME3... (spkg is script name)
and that this part "NAME1 NAME2 NAME3..." be variable PKG. Instead currently whole "-i NAME1 NAME2 NAME3... " is considered as PKG.
-i is position parameter $1 as it should, but how to avoid including it into $PKG. Something that says $2...
Offline
Are you looking for
shift
?
Wow.. with just adding "shift 1" it now works. Thanks man!
Last edited by simargl (2013-03-14 16:30:52)
Offline