summaryrefslogtreecommitdiff
path: root/src/shblg.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/shblg.sh')
-rwxr-xr-xsrc/shblg.sh24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/shblg.sh b/src/shblg.sh
index 8637bcd..61ef7db 100755
--- a/src/shblg.sh
+++ b/src/shblg.sh
@@ -11,23 +11,22 @@ usage () {
while getopts ":o:i:h" opt; do
case "$opt" in
o)
- OUTPUT_DIR=$OPTARG/
- mkdir -p $OUTPUT_DIR
- OUTPUT_DIR=$(realpath $OUTPUT_DIR)
+ OUTPUT_DIR="$OPTARG/"
+ mkdir -p "$OUTPUT_DIR"
+ OUTPUT_DIR="$(realpath "$OUTPUT_DIR")"
;;
i)
- INPUT_DIR=$(realpath $OPTARG)
+ INPUT_DIR="$(realpath "$OPTARG")"
;;
- h)
- usage
+ *) usage
;;
esac
done
# process a file to
process () {
- path="${1#$INPUT_DIR}"
- dirpath="${1%${1##*/}}"
+ path="${1#"$INPUT_DIR"}"
+ dirpath="${1%"${1##*/}"}"
out_file="${OUTPUT_DIR}${path}"
printf "%s ...\n" "$path"
@@ -36,15 +35,14 @@ process () {
mkdir -p "$out_file"
for f in "$1"/*; do
process "$f"
- done
+ done
return 0
- } || [ -x "$1" ] && {
+ } || [ -x "$1" ] && (
# execute the file
- cd $dirpath
+ cd "$dirpath"
"$1" > "${out_file}"
- cd -
return 0
- } || {
+ ) || {
# just copy the file as is
cp "$1" "$out_file"
return 0