allow execution from other paths
This commit is contained in:
parent
1758c6d72a
commit
093b490ce0
17
cscript
17
cscript
@ -10,6 +10,7 @@ if [ -z "$1" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Get file names, options and passed-through args
|
# Get file names, options and passed-through args
|
||||||
|
basedir="."
|
||||||
files=""
|
files=""
|
||||||
opts=""
|
opts=""
|
||||||
shebang_mode=""
|
shebang_mode=""
|
||||||
@ -19,7 +20,8 @@ arg() {
|
|||||||
if [ -z "$shebang_mode" ] && [ -n "$at_args" ]; then
|
if [ -z "$shebang_mode" ] && [ -n "$at_args" ]; then
|
||||||
args="$args\n$1"
|
args="$args\n$1"
|
||||||
elif [ "$shebang_mode" = "next_is_file" ]; then
|
elif [ "$shebang_mode" = "next_is_file" ]; then
|
||||||
files="$files\n$1"
|
basedir="$(dirname "$1")"
|
||||||
|
files="$files\n$(basename "$1")"
|
||||||
shebang_mode=1
|
shebang_mode=1
|
||||||
elif [ -n "$shebang_mode" ]; then
|
elif [ -n "$shebang_mode" ]; then
|
||||||
args="$args\n$1"
|
args="$args\n$1"
|
||||||
@ -43,9 +45,6 @@ arg() {
|
|||||||
;;
|
;;
|
||||||
# Add source file
|
# Add source file
|
||||||
*)
|
*)
|
||||||
[ ! -f "$1" ] && [ ! -L "$1" ] &&
|
|
||||||
echo "Source file '$1' does not exist" &&
|
|
||||||
exit 1
|
|
||||||
files="$files\n$1"
|
files="$files\n$1"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -59,7 +58,17 @@ files="$(echo -n "$files" | grep '.')"
|
|||||||
opts="$(echo -n "$opts" | grep '.')"
|
opts="$(echo -n "$opts" | grep '.')"
|
||||||
args="$(echo -n "$args" | grep '.')"
|
args="$(echo -n "$args" | grep '.')"
|
||||||
|
|
||||||
|
cd "$basedir"
|
||||||
|
|
||||||
|
# Check for invalid files
|
||||||
[ -z "$files" ] && echo "No input files" && exit 1
|
[ -z "$files" ] && echo "No input files" && exit 1
|
||||||
|
while IFS= read -r l; do
|
||||||
|
[ ! -f "$l" ] && [ ! -L "$l" ] &&
|
||||||
|
echo "Source file '$l' does not exist" &&
|
||||||
|
exit 1
|
||||||
|
done << EOF
|
||||||
|
$files
|
||||||
|
EOF
|
||||||
|
|
||||||
# Compile and run C program
|
# Compile and run C program
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
Loading…
Reference in New Issue
Block a user