New answers tagged

1

We have a simple bug - using lsof -t causes it to print one line per process rather than one line per socket. If we want to observe changes to the open sockets as claimed in the question, then we'll want something like lsof -i -b -n -F 'n' | grep '^n'. Instead of using lsof, it may be more efficient to use netstat; on my lightly-loaded system it's about 10-...


1

Temporary files Don't assume that /tmp/ is the right location for temporary files - if $TMPDIR is set, we should prefer that directory instead (e.g. which pam_tmpdir is used for per-user temp directories). It's a good idea to create a single directory for all the script's temporary files, then we can arrange for it to be cleaned up however the script exits: ...


1

The installer script should not ignore errors. As an example, in make > /dev/null cp ds_engine ~/.ds/ds_engine the make command can fail (if no compiler is installed, if there are syntax errors in the program, etc.). In such a case it makes no sense to copy the binary to the installation directory, or to execute any of the subsequent commands. That will ...


2

Patterns like: grep $1 $tag_file > /dev/null if [ $? != 0 ]; then ... fi Can be rewritten as: if grep -q $1 $tag_file; then ... fi


1

Do you want to make persistent temporary files? Note that while the default settings for mktemp put things in /tmp so that it will eventually get garbage collected, it doesn't immediately get garbage collected. Things can persist in /tmp for days. cat has a return code I'm not sure why are returning the return code from cat. Wouldn't it make more sense to ...


Top 50 recent answers are included