On Sun, Sep 21, 2014 at 4:06 PM, andrew mcelroy <[email protected]> wrote:
> Greetings all,
>
> This is probably a dumb questions, but I am writing a basic shell
> script that is passing $@ to a command. The issue is I'd like to
> filter $@ so that it does not pass a specific flag ( in this case
> --xcode-dir) ? How can I drop this in a bash script?
Assuming you want to drop the argument (value) after --xcode-dir as well:
#!/usr/bin/env bash
args=("$@")
myargs=()
nextarg=-1
for ((i=0; i<$#; i++)) {
if [ $nextarg == $i ]; then continue; fi
case ${args[$i]} in
--xcode-dir) nextarg=$((i+1)) ;;
*) myargs+="${args[$i]} "
esac
}
echo $myargs
./remove_xcode --xcode-dir foo --bar baz
--bar baz
--
Greg Donald
--
--
You received this message because you are subscribed to the Google Groups
"NLUG" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nlug-talk?hl=en
---
You received this message because you are subscribed to the Google Groups
"NLUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.