aboutsummaryrefslogtreecommitdiff
path: root/bin/mex
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-04-05 20:06:39 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-04-05 20:46:47 +1200
commitc8ab406749124d2e762ad5cf53963070113afd0f (patch)
tree54c9721a06957ebe7098a211eea803b0230c0f5d /bin/mex
parentHandle POSIX correctness in ~/.bash_profile (diff)
downloaddotfiles-c8ab406749124d2e762ad5cf53963070113afd0f.tar.gz
dotfiles-c8ab406749124d2e762ad5cf53963070113afd0f.zip
Apply runtime shebanging to POSIX shell
Diffstat (limited to 'bin/mex')
-rwxr-xr-xbin/mex53
1 files changed, 0 insertions, 53 deletions
diff --git a/bin/mex b/bin/mex
deleted file mode 100755
index 005149d8..00000000
--- a/bin/mex
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/sh
-# Make the first non-executable instance of files with the given names in $PATH
-# executable
-self=mex
-
-# Check we have at least one argument
-if [ "$#" -eq 0 ] ; then
- printf >&2 '%s: At least one name required\n' "$self"
- exit 2
-fi
-
-# Iterate through the given names
-for name ; do
-
- # Clear the found variable
- found=
-
- # Start iterating through $PATH, with colon prefix/suffix to correctly
- # handle the fenceposts
- path=:$PATH:
- while [ -n "$path" ] ; do
-
- # Pop the first directory off $path into $dir
- dir=${path%%:*}
- path=${path#*:}
-
- # Check $dir is non-null
- [ -n "$dir" ] || continue
-
- # If a file with the needed name exists in the directory and isn't
- # executable, we've found our candidate and can stop iterating
- if [ -f "$dir"/"$name" ] && ! [ -x "$dir"/"$name" ] ; then
- found=$dir/$name
- break
- fi
- done
-
- # If the "found" variable was defined to something, we'll try to change its
- # permissions
- if [ -n "$found" ] ; then
- chmod +x -- "$found" || ex=1
-
- # If not, we'll report that we couldn't find it, and flag an error for the
- # exit status
- else
- printf >&2 '%s: No non-executable name "%s" in PATH\n' "$self" "$name"
- ex=1
- fi
-done
-
-# We exit 1 if any of the names weren't found or if changing their permissions
-# failed
-exit "${ex:-0}"