Good joke (Was: Re: [MailServer Notification]Attachment Blocking Notification)

Steffen Nurpmeso steffen at sdaoden.eu
Wed Feb 14 20:18:18 UTC 2024


Administrator wrote in
 <27769766AF8F4611A87C44993387EA1A at ARRS.ARRISI.com>:
 |The quote-rndtrip.sh has been blocked since it violated the Microsoft 
 |Exchange attachment policy and Delete entire message has been taken on 
 |2/14/2024 3:12:02 PM.
 |If you have any questions, please contact ARRIS IT. Thank you
 |
 |Message details:
 |Server: ATLEXOWA3
 |Found in: SMTP
 |Sender: steffen at sdaoden.eu;
 |Recipient: harv at gmx.de;busybox at busybox.net;
 |Subject: Re: Failing shell code under busybox 1.36.1 that worked with 
 |1.31.1
 |Attachment name: quote-rndtrip.sh 
 --End of <27769766AF8F4611A87C44993387EA1A at ARRS.ARRISI.com>

I almost laughed.
Then inline.

And good-bye.

#!/bin/sh -
#@ Round trip quote strings in POSIX shell.  For example
#@   set -- x 'a \ b' "foo'" "\\'b\\a\\r\\" Aä
#@   printf "%s: <%s><%s><%s><%s><%s>\n" "$#" "${1}" "${2}" "${3}" "$4" "$5"
#@   saved_parameters=`quote_rndtrip "$@"`
#@   eval "set -- $saved_parameters"
#@   printf "%s: <%s><%s><%s><%s><%s>\n" "$#" "${1}" "${2}" "${3}" "$4" "$5"
#
# 2017 Robert Elz (kre).
# 2017 - 2022 Steffen Nurpmeso <steffen at sdaoden.eu>.
# Public Domain

# Though slower use a subshell version instead of properly restoring $IFS
# and flags, as elder shells may not be able to properly restore flags via
# "set +o" as later standardized in POSIX, and it seems overkill to handle
# all possible forms of output "set +o" may or may not actually generate.
quote__rndtrip() (
	case "$1" in
	*\'*) ;;
	*) printf "'%s'" "$1"; return 0;;
	esac
	a="$1" s= e=
	while case "$a" in
		\'*) a=${a#?}; s="${s}\\\\'";;
		*\') a=${a%?}; e="${e}\\\\'";;
		'') printf "${s}${e}"; exit 0;;
		*) false;;
		esac
	do
		continue
	done
	IFS=\'
	set -f
	set -- $a
	r="${1}"
	shift
	for a
	do
		r="${r}'\\''${a}"
	done
	printf "${s}'%s'${e}" "${r}"
	exit 0
)

quote_rndtrip() (
	j=
	for i
	do
		[ -n "$j" ] && printf ' '
		j=' '
		quote__rndtrip "$i"
	done
)

quote_string() (
	j=
	for i
	do
		[ -n "$j" ] && printf '\\ '
		j=' '
		quote__rndtrip "$i"
	done
)

# s-sht-mode

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)


More information about the busybox mailing list