scripts: run.sh
This commit is contained in:
parent
5aff16aea7
commit
0312a9188d
2
Makefile
2
Makefile
|
@ -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
41
scripts/run.sh
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user