Hi Dima,
great script! Love it! ❤️
I have some suggestion and ideas, maybe you would like to consider them:
-
I used shellcheck (package ShellCheck) as it checks for warnings, code smells etc. I can highly recommend it as Frank uses it for daps as well.
-
In the usage() function you use $0. This is certainly possible, but if $0 contains a path it will also show in the output. That can make the output ugly and a bit unreadable. I'd recommend to always add an additional line to create the base name of the script:
# Basename of the script
ME="${0##*/}"
In the usage() function use $ME instead of $0.
-
In line 107 you write to /tmp with a fixed filename. That can be dangerous as it can be abused ("man in the middle" attacks?). I'd recommend to use random filenames created by mktemp.
-
Maybe a minor thing, but config files are defined by the XDG Base Directory specification. It's from the Free Desktop initiative. User directories are stored in $HOME/.config.
If you want to consider it, you could check for $HOME/.otto.cfg and $HOME/.config/otto/otto.cfg and load whatever is available. If you really want to adhere to the spec, you could also check the XDG_CONFIG_HOME environment variable. I know, more code, but also more flexible.
-
Using the cd command is possible, but if you want to change directories back and forth, maybe look also for the built-in commands pushd and popd.
Keep up the great work!
Hi Dima,
great script! Love it! ❤️
I have some suggestion and ideas, maybe you would like to consider them:
I used
shellcheck(packageShellCheck) as it checks for warnings, code smells etc. I can highly recommend it as Frank uses it for daps as well.In the
usage()function you use$0. This is certainly possible, but if$0contains a path it will also show in the output. That can make the output ugly and a bit unreadable. I'd recommend to always add an additional line to create the base name of the script:In the
usage()function use$MEinstead of$0.In line 107 you write to
/tmpwith a fixed filename. That can be dangerous as it can be abused ("man in the middle" attacks?). I'd recommend to use random filenames created bymktemp.Maybe a minor thing, but config files are defined by the XDG Base Directory specification. It's from the Free Desktop initiative. User directories are stored in
$HOME/.config.If you want to consider it, you could check for
$HOME/.otto.cfgand$HOME/.config/otto/otto.cfgand load whatever is available. If you really want to adhere to the spec, you could also check theXDG_CONFIG_HOMEenvironment variable. I know, more code, but also more flexible.Using the
cdcommand is possible, but if you want to change directories back and forth, maybe look also for the built-in commandspushdandpopd.Keep up the great work!