summaryrefslogtreecommitdiff
path: root/src/shblg.sh
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2023-12-31 01:25:56 +0000
committerdavidovski <david@davidovski.xyz>2023-12-31 01:25:56 +0000
commitf8b8b0a7cad96c648c896fa6eb660fdb988dfdb2 (patch)
treeef18e1c4a5c13c19906f494789e38a2573d6c2ff /src/shblg.sh
parentfa405f8fbff5ad6e73b0dfa887165986e037d1fd (diff)
reformat
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