annotate bin/f @ 11258:edaf8efd6e21

<oerjan> learn This is something people on the channel like to talk about. We\'re often unsure what this is, though.
author HackBot
date Sat, 09 Dec 2017 11:45:07 +0000
parents c989a1669243
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9075
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
1 #! /bin/bash
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
2 cmd="$1"
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
3 shift
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
4 f="$*"
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
5 if [[ -z "$f" && "$cmd" == *\ * ]]; then f="${cmd#* }"; cmd="${cmd%% *}"; fi
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
6 if [[ -z "$f" ]]; then echo try: \`f command filename; elif [[ -e "$f" ]]; then "$cmd" "$(< "$f")"; else echo no such file: "$f"; fi