@
Jonathan Kamens…a way which, as I've already explained, is wrong.
For the rest of you, I inform you that the above arguments are ridiculous.
And that's why.
1) It will do the wrong thing if multiple scripts on your system have the same basename.
Yes, it's a colossal problem. After all, we can't not use basename.
2) It won't work for scripts whose names are more than 15 characters long.
Really?
# ps auxw | grep test0123456789123456.sh
root 835628 0.0 0.0 2892 940 pts/0 S 15:28 0:00 /bin/sh ./test0123456789123456.sh
root 835657 0.0 0.0 6628 2448 pts/0 S+ 15:28 0:00 grep --color=auto test0123456789123456.sh
# echo test0123456789123456.sh | wc -c
243) At least in Debian, pgrep is not available on every system but flock is.
This is a huge problem.
Since my opponent doesn't want to think and apparently doesn't know how to think very well, I'll do it for him.
[ $(ps auxw | grep $0 | grep -v grep | wc -l) -gt 1 ] && exitor shorter but less obvious
[ $(ps auxw | grep $0 | wc -l) -gt 2 ] && exitWorks on any UNIX-like system.
In general, it saddens me to see this level of incompetence, particularly if the opponent's stated seniority is consistent with reality.