diff options
author | thaiel <thaiel@texto-plano.xyz> | 2022-06-01 16:30:11 +0000 |
---|---|---|
committer | thaiel <thaiel@texto-plano.xyz> | 2022-06-01 16:30:11 +0000 |
commit | 15bb5361146da6e1a8a07dcf72d2963b4e2d97db (patch) | |
tree | 64cffffa08dcae61ebeefb4c1fc73eb7e144b83e | |
download | coment.ar-15bb5361146da6e1a8a07dcf72d2963b4e2d97db.tar.gz |
Primera
-rwxr-xr-x | coment.ar | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/coment.ar b/coment.ar new file mode 100755 index 0000000..4cc4487 --- /dev/null +++ b/coment.ar @@ -0,0 +1,41 @@ +#!/bin/sh + +if [ "1" != "$#" ]; then + echo 'Número incorrecto de parámetros!!' + echo 'USO:' + echo "$0 usuario_destino" + return 2 +fi +echo Ingrese el nombre del archivo +echo en el que quiere comentar +read z +destino="$1" +autor="$USER" + +if [ "$EDITOR" == "" ]; then + EDITOR="nano" +fi + +tmpfile=$(mktemp) + +$EDITOR "$tmpfile" + +if [ ! -s "$tmpfile" ]; then + echo "El archivo esta vació, abortando." + rm "$tmpfile" + return 1 +fi + +date=$(date +"%Y-%m-%d") + +{ + printf '<hr/>\n<p>%s - <strong>%s</strong>:</p>\n' "$date" "$autor" + printf '<pre>' + cat "$tmpfile" | + sed 's|&|\&|g;s|<|\<|g;s|>|\>|g' + printf '</pre>\n' +} >> /home/$destino/public_html/com/${z}.html + +rm "$tmpfile" + +return 0 |