Hacker News new | ask | show | jobs
by saurik 1041 days ago
"$@" would have worked just as well there, instead of the final three lines: you pulled cmd off the front just to... put it back. (I wouldn't recommend doing either of these, though, as it is weird that random other commands are valid there, such as "ls"; you should use a case statement.)
2 comments

Yes, I think I used to check if `$cmd` was in a space separated list of valid commands, but I don't anymore because I only every use this to quickly get some commands down into a project's directory so as not to forget them.

As soon as any complexity or validation is needed I move to python, which is usually a better fit, and arguably even more portable.

I suppose it's safer that way because it will only execute those specific functions, and wouldn't, for example, execute a statement like "rm -rf /”