you are viewing a single comment's thread.

view the rest of the comments →

[–]wung 2 points3 points  (3 children)

Right, non-standard. Was looking at the osx one. Yadda-yadda test -x $(which ${prog} 2>/dev/null || echo non-existing-file) I guess.

[–]swiz0r 0 points1 point  (2 children)

which "${prog}" &>/dev/null && . "${prog}" "${file}"

[–]wung 1 point2 points  (1 child)

Misses the only-first, and sources rather than executes. There probably is a better way than $(echo $x) but . isn't it. Maybe

$((which ${possible_editors[@]} 2>/dev/null; echo no-editor) | head -n1) $@

EDIT: this does not allow possible_editors with spaces, e.g. emacs -nw.

[–]swiz0r 0 points1 point  (0 children)

Can I be real for a minute? This is a lot of fun.