Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • Your second suggestion — comparing the filtering substitution to the full substitution — works reasonably well, and has the advantage of not disrupting the list of arguments. Commented May 30, 2017 at 13:46
  • Could you explain what the second suggestion (especially ${@#) does?
    – velop
    Commented Nov 14, 2017 at 16:01
  • 1
    @velop Sure! So you know that $@ is a special variable that holds all of the command line arguments? Well I've just used Bash string manipulation on that variable to remove the substring "-disableVenusBld", and then I compare it to the original $@. So if $@ equals -foo -bar then ${@#-disableVenusBld} would still be -foo -bar, so I can see that the flag I'm looking for isn't present. However, if $@ equals -foo -disableVenusBld -bar then ${@#-disableVenusBld} would be -foo -bar which is not equal to $@, thus telling me that the flag I'm looking for is present! Cool eh!
    – Rich
    Commented Nov 14, 2017 at 20:23
  • @velop Learn more about Bash string manipulation here: tldp.org/LDP/abs/html/string-manipulation.html
    – Rich
    Commented Nov 14, 2017 at 20:29
  • @Rich pretty neat ^^, thx for the explanation.
    – velop
    Commented Nov 17, 2017 at 10:21