[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Support ksh93 x=${<space>cmd;}
From: |
Sam James |
Subject: |
Re: Support ksh93 x=${<space>cmd;} |
Date: |
Wed, 09 Apr 2025 07:25:57 +0100 |
User-agent: |
mu4e 1.12.9; emacs 31.0.50 |
Cedric Blancher <cedric.blancher@gmail.com> writes:
> Good morning!
>
> Could bash please support x=${<space>cmd;} alongside x=$(cmd)?
>
> x=$(<space>cmd;} works like x=$(cmd), except that cmd does not run in
> a subshell, i.e. the stdout within ${<space>cmd;} is redirected to the
> variable "x", but any other changes of variables (global/static/local)
> are also available outside ${}, unlike $()
>
> <space> can be anything of blank, tab, newline. The cmd must ALWAYS be
> terminated with a ";".
>
> Example:
> ksh93 -c 'out_stderr="${ { out_stdout="${ ls x ; (( out_res=$? )) ; }"
> ; } 2>&1 ; }" ; printf "stdout=%q, stderr=%q, exit code=%d\n"
> "$out_stdout" "$out_stderr" "$out_res"'
> stdout='', stderr=$'ls: cannot access \'x\': No such file or
> directory', exit code=2
See https://lists.gnu.org/archive/html/bug-bash/2025-04/msg00023.html.
Re: Support ksh93 x=${<space>cmd;}, Dan Shelton, 2025/04/09