makeWrapper: Only wrap normal executable files
`makeWrapper` and `wrapProgram` are being invoked on all kinds of wacky things (usually with the help of bash globs or other machine assistance). So far, I have come across `wrapProgram` being invoked on a directory, as well as on the empty string. As far as I can tell, it's only valid to invoke these utilities on a normal (non-directory, non-device) executable file. This commit enforces that precondition.
This commit is contained in:
parent
ba68231273
commit
e1d46c0c4d
@ -1,3 +1,12 @@
|
||||
# Assert that FILE exists and is executable
|
||||
#
|
||||
# assertExecutable FILE
|
||||
assertExecutable() {
|
||||
local file="$1"
|
||||
[[ -f "${file}" && -x "${file}" ]] || \
|
||||
die "Cannot wrap ${file} because it is not an executable file"
|
||||
}
|
||||
|
||||
# construct an executable file that wraps the actual executable
|
||||
# makeWrapper EXECUTABLE ARGS
|
||||
|
||||
@ -24,6 +33,8 @@ makeWrapper() {
|
||||
local params varName value command separator n fileNames
|
||||
local argv0 flagsBefore flags
|
||||
|
||||
assertExecutable "${file}"
|
||||
|
||||
mkdir -p "$(dirname "$wrapper")"
|
||||
|
||||
echo "#! $SHELL -e" > "$wrapper"
|
||||
@ -131,6 +142,9 @@ filterExisting() {
|
||||
wrapProgram() {
|
||||
local prog="$1"
|
||||
local hidden
|
||||
|
||||
assertExecutable "${prog}"
|
||||
|
||||
hidden="$(dirname "$prog")/.$(basename "$prog")"-wrapped
|
||||
while [ -e "$hidden" ]; do
|
||||
hidden="${hidden}_"
|
||||
|
Loading…
Reference in New Issue
Block a user