Failing shell code under busybox 1.36.1 that worked with 1.31.1

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


Hello.

Harvey wrote in
 <031f00da-4016-4311-b397-1c04e373d521 at gmx.de>:
 |Sorry, posted the wrong version of the pack_args() funtion:
 |I have payed with possible solutions for so long that I forgot the
 |restore the original before posting  -blush-
 |
 |Here is the original version:
 |------------------------------------------------------------------------
 |
 |# Packs arguments into a single string.
 |#
 |# Input:
 |#   $1 = name of variable receiving the arguments in such a way that
 |#        (re)evaluating them provides the original arguments
 |#   $2... = arguments

Dunno about yours, but Robert Elz (kre) did such in a way that is
portable to any shell i tried it with (// is definitely not
portable); with only slight changes of mine, as attached.

 |# Example:
 |#   func() {
 |#     local args
 |#     pack_args args "$@"
 |#     send_rpc func_impl "$args"
 |#   }
 |#   # (in another process)
 |#   receive_rpc() {
 |#     local func="$1"
 |#     local args="$2"
 |#     eval $func "$args"
 |#   }
 |pack_args()
 |{
 |     local _p _resvar=$1 _result= _value
 |     shift
 |     for _p
 |     do
 |         _result="$_result '${_p//'/'\"'\"'}'"
 |     done
 |     eval $_resvar=\${_result\# }
 |}

--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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: quote-rndtrip.sh
Type: text/x-shellscript
Size: 1341 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20240214/18036e4e/attachment.bin>


More information about the busybox mailing list