3 ms·
I've got several Bash aliases that are "wrappers" around functions like that and which help "fix" commands / find common mistakes. The one thing to keep in min
by TacticalCoder 3y ago
I've got several Bash aliases that are "wrappers" around functions like that and which help "fix" commands / find common mistakes.
The one thing to keep in mind while doing that is that you should not modify how a command behaves in the happy case and your wrapper should only be used when using the shell yourself. Do not wrap commands and then use the wrapper from shell scripts, for example. Otherwise you'll be sorry out of luck if you copy your script to another script.
- yonatan8070 3y agoSounds interesting, do you have a repo with your fixes somewhere?
- ithkuil 3y agoI agree. But on the flip side if you only use functions you can't use them in xargs, parallel etc. So I often so use my own wrapper scripts in a dir in front of PATH and I pay the price of occasionally sharing bad scripts with my coworkers. Most of the time those broken scripts are caught by CI but not all scripts are... I know that technically I could wrap /bin/sh /bin/bash with a wrapper that strips my wrapper dir from PATH but that's too invasive and I don't want to do that. I wonder if there is a trick? Perhaps some pre-run hook that one can register in some advanced shells (e.g. I actually use zsh)?