bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFE: Make `printf -v var` support positional parameters


From: microsuxxor
Subject: Re: RFE: Make `printf -v var` support positional parameters
Date: Thu, 5 Dec 2024 17:54:29 +0100

~ $ IFS=' ' ; declare -a "a=( $( printf %q\  1 two ' th r ee ' '$( four >&2
)' ) )" ; set -- "${a[@]}" ; printf -- -%s-\ \  "$@" ; printf \\n
-1-  -two-  - th r ee -  -$( four >&2 )-

On Thu, Dec 5, 2024, 5:48 PM Chet Ramey <chet.ramey@case.edu> wrote:

> On 12/5/24 9:41 AM, Clark Wang wrote:
> > It would be easier to manipulate positional params if we can write like
> > `printf -v 1`.
>
> Use an array. Use printf to write values to the array elements, then use
> set -- "${array[@]}" (or "${array[@]:1}" depending on how closely you
> want the array to parallel the positional parameters) to set the positional
> parameters.
>
> Chet
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]