|
@@ -8,6 +8,7 @@ fi
|
|
|
LOG_ROOT="$HOME"/.local/var/log/shell # source this
|
|
|
|
|
|
LIST_MODE=false
|
|
|
+ORS='\n'
|
|
|
|
|
|
usage () {
|
|
|
cat <<EOF
|
|
@@ -32,10 +33,14 @@ the captured exit status.
|
|
|
- List at most 10 paths to all captured find commands
|
|
|
|
|
|
${0##*/} -l -n 10 find
|
|
|
+
|
|
|
+ - List paths null delimited for pipe (in case of paths with new line char)
|
|
|
+
|
|
|
+ ${0##*/} -l -z find | xargs -r -0 ls -lahd
|
|
|
EOF
|
|
|
}
|
|
|
|
|
|
-OPTSTRING=":hln:"
|
|
|
+OPTSTRING=":hln:z"
|
|
|
parse_opt () {
|
|
|
case "${opt}" in
|
|
|
h)
|
|
@@ -56,6 +61,9 @@ parse_opt () {
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
+ z)
|
|
|
+ ORS='\0'
|
|
|
+ ;;
|
|
|
\?)
|
|
|
echo "Unknown switch: -$OPTARG" >&2
|
|
|
echo >&2
|
|
@@ -125,14 +133,17 @@ awk_rw0_strip_first_path_part () {
|
|
|
|
|
|
}
|
|
|
|
|
|
-awk_rw0_add_prefix () {
|
|
|
+awk_r0_add_prefix () {
|
|
|
# NOTE: some-string -> <prefix>some-string (null delimited)
|
|
|
- : "${1?awk_rw0_add_prefix requires exactly one positional arg}"
|
|
|
- [ "${1+DefinedMaybeEmpty}" == "DefinedMaybeEmpty" ]
|
|
|
+ : "${2?awk_r0_add_prefix requires exactly two positional args}"
|
|
|
+ : "${1:?awk_r0_add_prefix output record separator must be set and non-empty}"
|
|
|
+ [ "${1:+DefinedNotEmpty}" == "DefinedNotEmpty" ]
|
|
|
+ [ "${2+DefinedMaybeEmpty}" == "DefinedMaybeEmpty" ]
|
|
|
awk \
|
|
|
- -v prefix="$1/" \
|
|
|
+ -v prefix="$2/" \
|
|
|
-v RS='\0' \
|
|
|
- -v ORS='\n' '{print prefix $0}' \
|
|
|
+ -v ORS="$1" \
|
|
|
+ '{print prefix $0}' \
|
|
|
&& :
|
|
|
}
|
|
|
|
|
@@ -159,8 +170,8 @@ then
|
|
|
| head -zn "${NUM:--0}" \
|
|
|
| fzf_rw0_inplace_preview \
|
|
|
| awk_rw0_strip_first_path_part \
|
|
|
- | awk_rw0_add_prefix "$LOG_ROOT" \
|
|
|
- && : "TODO: allow configuring null terminated output"
|
|
|
+ | awk_r0_add_prefix "$ORS" "$LOG_ROOT" \
|
|
|
+ && :
|
|
|
)
|
|
|
else
|
|
|
SUBPROG=""
|