ajout newfile.sh
This commit is contained in:
parent
4a16469559
commit
6f6aad9c05
|
@ -0,0 +1,42 @@
|
||||||
|
#!/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
|
Loading…
Reference in New Issue