From 8b23667b4e7435e96a60d99c3f5e5e9583237b18 Mon Sep 17 00:00:00 2001 From: filip <“filip.rabiega@gmail.com”> Date: Tue, 23 Sep 2025 13:55:43 +0200 Subject: new stuff --- newscript | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'newscript') diff --git a/newscript b/newscript index c251e20..0b47bbd 100755 --- a/newscript +++ b/newscript @@ -1,12 +1,13 @@ #!/bin/sh newscript () { - path="$HOME/.scripts/$1" - touch "$path" && printf "#!/bin/sh\n\n" > "$path" && "$EDITOR" +2 "$path" - if [ "$( wc -l "$path" | awk '{print $1}' )" -lt 3 ]; then - rm -f "$path" + 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 "$path" + chmod +x "$file" fi } -- cgit v1.2.3