diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-08-30 08:23:45 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-08-30 08:23:45 +0200 |
commit | 3f8594ee04d2a3d9b40a259daf3b564a53b510fa (patch) | |
tree | 66ed50643cdc81af813b5771a99732d0f78bb618 /bin/common/toush | |
parent | 45d39ae0c67bb086f4df0c366b251e06c888408d (diff) | |
parent | 333aaf38c66a1e4ba41d3acea38b21613c0075b2 (diff) |
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin/common/toush')
-rwxr-xr-x | bin/common/toush | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/bin/common/toush b/bin/common/toush index dd675b9..eb2d7cf 100755 --- a/bin/common/toush +++ b/bin/common/toush @@ -1,14 +1,10 @@ #!/bin/sh -# fork of -# https://codeberg.org/futxlii/bin/toush :) +# idea from https://codeberg.org/futxlii/bin/toush :) shebang='#!/bin/sh' -usage() { >&2 printf 'Usage: %s' "${0##*/}"; exit 1 ;} +[ -f "$1" ] && exit 1 -[ "$1" ] || usage -while [ "$1" ]; do - [ -f "$1" ] && usage - printf '%s\n\n' "$shebang" > "$1" && chmod +x "$1" - shift -done +printf '%s\n\n' "$shebang" > "$1" && + chmod +x "$1" && $EDITOR "$1" +grep -qv "$shebang\|^$" "$1" || rm "$1" |