scripts: run.sh

This commit is contained in:
corey 2024-02-01 12:42:50 -06:00
parent 5aff16aea7
commit 0312a9188d
3 changed files with 42 additions and 1 deletions

View File

@ -35,7 +35,7 @@ all: lr
liblr.a: $(OBJS)
$(AR) rc $@ $^
version.h:
./update_ver.sh
./scripts/update_ver.sh
lr: version.h main.o liblr.a
$(CC) $(filter-out %.h, $^) -o $@ $(LDFLAGS)
tests_i386: lr tests/i386/bin $(addprefix tests/i386/bin/, $(TESTS_i386)) $(addprefix tests/i386/bin/, $(TESTS_i386)) FORCE

41
scripts/run.sh Normal file
View File

@ -0,0 +1,41 @@
#!/bin/bash
#
# Run executable file found in
# $PATH or local directory, then
# print return code
#
# Use by sourcing this file (`. run.sh`)
# alias r=run
fixvars()
{
IFS="$OIFS"
PATH="$OPATH"
}
run()
{
OIFS="$IFS"
OPATH="$PATH"
if [ "$1" = '' ]; then
echo "usage: run CMD"
return 1
fi
PATH="$PATH:./"
IFS=':'
for p in $PATH; do
if [ -e "$p/$1" ]; then
"$p"/$*;echo $?
fixvars
return 0
fi
done
echo "error: cannot find $1"
fixvars
return 1
}