diff options
author | filip <“filip.rabiega@gmail.com”> | 2025-09-23 13:55:43 +0200 |
---|---|---|
committer | filip <“filip.rabiega@gmail.com”> | 2025-09-23 13:55:43 +0200 |
commit | 8b23667b4e7435e96a60d99c3f5e5e9583237b18 (patch) | |
tree | 1f5f49aecf38948f03de978aac0db49c0b9e7143 /newscript | |
parent | e4ea00cfc9fc7340c62dd920b4754787c4499de6 (diff) | |
download | chadscripts-8b23667b4e7435e96a60d99c3f5e5e9583237b18.tar.gz chadscripts-8b23667b4e7435e96a60d99c3f5e5e9583237b18.tar.bz2 chadscripts-8b23667b4e7435e96a60d99c3f5e5e9583237b18.zip |
new stuff
Diffstat (limited to 'newscript')
-rwxr-xr-x | newscript | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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 } |