summaryrefslogtreecommitdiff
path: root/newscript
diff options
context:
space:
mode:
authorfilip <“filip.rabiega@gmail.com”>2025-10-10 19:10:02 +0200
committerfilip <“filip.rabiega@gmail.com”>2025-10-10 19:10:02 +0200
commit807de46d3a3cbef9a3c3c104f6db87b142e6eed5 (patch)
tree61a1a9bc26daad623ce6c04bb66ae39133ef0261 /newscript
parent08204fc9b9f63015a1dc083b471c6839818eeb59 (diff)
downloadchadscripts-807de46d3a3cbef9a3c3c104f6db87b142e6eed5.tar.gz
chadscripts-807de46d3a3cbef9a3c3c104f6db87b142e6eed5.tar.bz2
chadscripts-807de46d3a3cbef9a3c3c104f6db87b142e6eed5.zip
used shfmt
Diffstat (limited to 'newscript')
-rwxr-xr-xnewscript26
1 files changed, 16 insertions, 10 deletions
diff --git a/newscript b/newscript
index 0b47bbd..f6d11b0 100755
--- a/newscript
+++ b/newscript
@@ -1,17 +1,23 @@
#!/bin/sh
-newscript () {
- file="$HOME/.scripts/$1"
- [ -f "$file" ] && { echo "Script with the same name already exists, exiting" >&2; exit 1 ;}
- touch "$file" && printf "#!/bin/sh\n\n" > "$file" && "$EDITOR" +2 "$file"
- if [ "$( wc -l "$file" | awk '{print $1}' )" -lt 3 ]; then
- rm -f "$file"
- else
- chmod +x "$file"
- fi
+newscript() {
+ file="$HOME/.scripts/$1"
+ [ -f "$file" ] && {
+ echo "Script with the same name already exists, exiting" >&2
+ exit 1
+ }
+ touch "$file" && printf "#!/bin/sh\n\n" >"$file" && "$EDITOR" +2 "$file"
+ if [ "$(wc -l "$file" | awk '{print $1}')" -lt 3 ]; then
+ rm -f "$file"
+ else
+ chmod +x "$file"
+ fi
}
-[ "$#" -ne 1 ] && { echo "Usage: newscript <script-name>" >&2; exit 1; }
+[ "$#" -ne 1 ] && {
+ echo "Usage: newscript <script-name>" >&2
+ exit 1
+}
newscript "$1"
exit 0