nulib/bin/templ.sh

43 lines
989 B
Bash
Executable File

#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source /etc/nulib.sh || exit 1
: ${EDITOR:=vim}
executable=1
args=(
"créer un nouveau fichier .sh"
"<files...>"
-x,--exec executable=1 "créer un script exécutable"
-n,--no-exec executable= "créer un fichier non exécutable"
)
parse_args "$@"; set -- "${args[@]}"
[ $# -gt 0 ] || die "vous devez spécifier les noms des fichiers à créer"
for file in "$@"; do
[ -e "$file" ] && die "$file: fichier existant"
if [ -n "$executable" ]; then
cat >"$file" <<EOF
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source /etc/nulib.sh || exit 1
args=(
"description"
#"usage"
)
parse_args "\$@"; set -- "\${args[@]}"
EOF
chmod +x "$file"
"$EDITOR" +6 "$file"
else
cat >"$file" <<EOF
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
EOF
"$EDITOR" +2 "$file"
fi
done