rewrite sed script to avoid unnecessary pipe in '--man' option

This commit is contained in:
2021-04-30 11:58:41 +02:00
parent 6aa4b2cf97
commit ec99a02d4f

View File

@@ -69,14 +69,16 @@
# $ sudo dup-live-disk.sh sdb # $ sudo dup-live-disk.sh sdb
# #
# BUGS # BUGS
# Cannot generate grub with a separate /boot partition. # * Cannot generate grub with a separate /boot partition.
# This script will not work for all situations, I strongly suggest you # * This script will not work for all situations, I strongly suggest you
# don't use it if you don't *fully* understand it. # don't use it if you don't *fully* understand it.
# * Extended attributes are not preserved (easy fix, but I cannot test)
# #
# TODO # TODO
# Write about autofs configuration. # * Write about autofs configuration.
# Log levels # * Log levels
# Check existence of fstab for new disk and install it # * Check existence of prepared fstab on source root partition for
# destination root partition, and enable it.
#%MAN_END% #%MAN_END%
# command line # command line
@@ -88,7 +90,7 @@ CMD="${0##*/}"
VALIDFS=(ext3 ext4 btrfs vfat reiserfs xfs zfs) VALIDFS=(ext3 ext4 btrfs vfat reiserfs xfs zfs)
function man { function man {
sed -n '/^#%MAN_BEGIN%/,/^#%MAN_END%$/{//!p}' "$SCRIPT" | sed -E 's/^# ?//' sed -n '/^#%MAN_BEGIN%/,/^#%MAN_END%$/{//!s/^#[ ]\{0,1\}//p}' "$SCRIPT"
} }
function usage { function usage {
@@ -179,7 +181,7 @@ trap 'error_handler $LINENO $?' ERR SIGHUP SIGINT SIGTERM
function exit_handler { function exit_handler {
local mnt local mnt
log "exit handler (at line $1)" # log "exit handler (at line $1)"
mariadb_maybe_start mariadb_maybe_start
if [[ -n "$DSTMNT" ]] && mountpoint -q "$DSTMNT"; then if [[ -n "$DSTMNT" ]] && mountpoint -q "$DSTMNT"; then
for mnt in "$DSTMNT"/{dev,proc,sys}; do for mnt in "$DSTMNT"/{dev,proc,sys}; do