Re: Surprising behavior with inline environment variable expansion

2025-03-27 Thread Léa Gris
with the rest of the variables bash uses. Thank you Chet and all the others who gave good clarifications. I was just misled by the output of locale not always matching the environment variables. Now I understand it clearly. The bug was sitting in the chair in front of my computer. :) -- Léa Gris

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Léa Gris
t; LC_TIME="C" LC_COLLATE="C" LC_MONETARY="C" LC_MESSAGES="C" LC_PAPER="C" LC_NAME="C" LC_ADDRESS="C" LC_TELEPHONE="C" LC_MEASUREMENT="C" LC_IDENTIFICATION="C" LC_ALL=C I wonder if locale is switched accordingly to environment variables, but environment variables may not automatically switch to the new locale. -- Léa Gris

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Léa Gris
LANG=fr_FR.UTF-8 LANGUAGE=fr_FR:fr_CA:en LC_CTYPE="fr_FR.UTF-8" LC_NUMERIC=C LC_TIME=fr_FR.UTF-8 LC_COLLATE="fr_FR.UTF-8" LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES="fr_FR.UTF-8" LC_PAPER=fr_FR.UTF-8 LC_NAME=fr_FR.UTF-8 LC_ADDRESS=fr_FR.UTF-8 LC_TELEPHONE=fr_FR.UTF-8 LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=fr_FR.UTF-8 LC_ALL= Environment variable: LC_NUMERIC=C -- Léa Gris

Surprising behavior with inline environment variable expansion

2025-03-26 Thread Léa Gris
unterintuitive and inconsistent, making it difficult to predict how inline environment variables will affect both variable expansion and command execution. Some clarification in the Bash documentation could be helpful. Any insights on this would be greatly appreciated! Thanks, -- Léa Gris

Re: proposed BASH_SOURCE_PATH

2024-06-26 Thread Léa Gris
0 is a very different semantic than BASH_SOURCE. I don't even understand why BASH_SOURCE would point to anything other than the source path or the real source path if some option tells it to resolve real paths. -- Léa Gris

Re: proposed BASH_SOURCE_PATH

2024-06-20 Thread Léa Gris
re discussing. Would it be a valid option, then to make BASH_SOURCE contain the real path in all circumstances? -- Léa Gris

Re: proposed BASH_SOURCE_PATH

2024-06-19 Thread Léa Gris
this does not solve symbolic links and to do this, you need a sub-shell and it is not system agnostic anymore. realSource=$(realpath -- "${BASH_SOURCE[0]}") && realScriptDir=${realSource%/*} -- Léa Gris

Re: REQUEST - bash floating point math support

2024-06-17 Thread Léa Gris
atted and don't bother to set LC_NUMERIC=C before running this command A common pitfall is trying to parse the output of the time builtin command. It already breaks on locale ignorant scripts. This won't change. -- Léa Gris

Re: REQUEST - bash floating point math support

2024-06-16 Thread Léa Gris
literals. Anyway, this could be handled with existing bash string replacement feature: localeFormatted=3,1415 declare -i numvar=${localeFormatted/,/.} -- Léa Gris

Re: REQUEST - bash floating point math support

2024-06-15 Thread Léa Gris
double precision binary64 2. Outside a numerical context, when creating a string representation of a floating-point number, the LC_NUMERIC format applies. -- Léa Gris

Re: REQUEST - bash floating point math support

2024-06-15 Thread Léa Gris
Le 15/06/2024 à 02:49, Koichi Murase écrivait : 2024年6月14日(金) 16:18 Léa Gris : Another elegant option would be to expand the existing variables' i flag to tell the variable is numeric rather than integer. Then have printf handle argument variables with the numeric flag as using the LC_NU

Re: REQUEST - bash floating point math support

2024-06-14 Thread Léa Gris
nding the existing i flag would also ensure numerical expressions would handle the same value format. The David method: Take down multiple issues with one stone. -- Léa Gris

Re: REQUEST - bash floating point math support

2024-06-06 Thread Léa Gris
his exact overlook. -- Léa Gris

Re: REQUEST - bash floating point math support

2024-06-06 Thread Léa Gris
Le 06/06/2024 à 10:29, Koichi Murase écrivait : 2024年6月6日(木) 15:59 Léa Gris : Le 05/06/2024 à 17:09, Koichi Murase écrivait : 2024年6月5日(水) 21:41 Zachary Santer : Bash could potentially detect floating point literals within arithmetic expansions and adjust the operations to use floating point

Re: REQUEST - bash floating point math support

2024-06-06 Thread Léa Gris
.5 12 22 34 As long as you're OK with "banker's rounding", printf does it. As long as you are ok with your script breaking because of LC_NUMERIC local using a different decimal symbol like a comma in French. -- Léa Gris

Re: REQUEST - bash floating point math support

2024-06-05 Thread Léa Gris
is incompatible with systems whose locale use a decimal comma instead. -- Léa Gris

Re: proposed BASH_SOURCE_PATH

2024-05-14 Thread Léa Gris
m its symbolic link in current dir ./real_bash_source_dir_test You can see it is able to source its library relative to its real installed path and it works regardless of if called from a symbolic link or directly from its installed dir. -- Léa Gris

Re: proposed BASH_SOURCE_PATH

2024-05-14 Thread Léa Gris
./ Then you get same answer in both cases: ./tests/real_bash_source_dir_test ./real_bash_source_dir_test -- Léa Gris

Re: "${assoc[@]@k}" doesn't get expanded to separate words within compound assignment syntax

2024-03-20 Thread Léa Gris
trings and if anything else put the JSON text string as the value. But possibly people are overusing Bash and shell for things that it was not designed for. In a lot of case, more general purpose scripting language are available to a wide range of systems. When your favorite tool is a hamm

Re: Warn upon "declare -ax"

2023-09-04 Thread Léa Gris
are static analysis tools like Shellcheck which might be expanded to ware of such incompatible flags but that's it. -- Léa Gris

Re: bug#65659: RFC: changing printf(1) behavior on %b

2023-09-02 Thread Léa Gris
3AShell&type=code> Those actual numbers vary a lot depending on request accuracy. Because there is no Regex replacement for a shell language parser; it cannot match all syntactically valid use cases, even with a carefully crafted Regex. -- Léa Gris

Re: string substitution broken since 5.2

2022-11-04 Thread Léa Gris
side-effects? -- Léa Gris

Re: declare -x non-exportable variable types

2022-02-25 Thread Léa Gris
e result of exporting Bash variables with attributes is indeterminate"), which might be an appropriate clarification? -- Léa Gris

declare -x non-exportable variable types

2022-02-22 Thread Léa Gris
e export array # export with value of first elmeent export assoc # export empty value (same as referencing an associative array without a [key]. export upper; export lower # export with converted value export nameref # export with value of the referee This means that the export command would expand the variable value before exporting, but the declare, local and typeset statements would error if flags are incompatible with -x export. -- Léa Gris

Re: Long variable value get corrupted sometimes

2022-02-16 Thread Léa Gris
Le 16/02/2022 à 13:43, Greg Wooledge écrivait : text=$(cat /tmp/foo.txt; printf x) text=${text%x} or read -r -d '' text

Re: Interesting bug

2022-02-12 Thread Léa Gris
*)    exit 1     esac } } The bug is in your code. https://shellcheck.net/ static analysis for shell scripts can help you spot such syntax errors. -- Léa Gris

empty nameref issue

2021-11-28 Thread Léa Gris
that this limbo empty state of a nameref is only obtained with an initial `declare -n ref`. There is no way to later clear or assign an empty string to a nameref unless destroying and recreating the nameref with: unset -n ref declare -n ref -- Léa Gris

Re: Arbitrary command execution in shell - by design!

2021-10-30 Thread Léa Gris
deed, if a bash script is able to be abused, it is not bash's fault, neither the script's fault, but the system's security policies granting those privileges to the user running the script. -- Léa Gris

Re: Arbitrary command execution in shell - by design!

2021-10-29 Thread Léa Gris
nd genuine human errors, this is a red flag to avoid shell scripts and find a more suitable language/tool for this task. -- Léa Gris

Re: Arbitrary command execution from test on a quoted string

2021-10-28 Thread Léa Gris
NPUT" Would be: test "${USER_INPUT@Q}" But it is not backward-compatible with older bash versions. Alternatively: declare -p USER_INPUT >/dev/null 2>&1 will work with much older bash versions Any other way witch are less bulky and or more backward compatible? -- Léa Gris

declare does not always set variable flags prior to assignment

2021-10-04 Thread Léa Gris
declare +i -A assoc=([yeet]=hello) declare -p assoc declare -A assoc=([yeet]="0" ) -- Léa Gris

Re: Request change to output of declare -f funcname

2021-10-02 Thread Léa Gris
Le 02/10/2021 à 18:45, Greg Wooledge écrivait : On Sat, Oct 02, 2021 at 06:06:32PM +0200, Léa Gris wrote: Better illustrated how newlines are discarded: $ sudo bash -c 'echo hello echo world' hello world $ sudo -i bash -c 'echo hello echo world' helloecho world O

Re: Request change to output of declare -f funcname

2021-10-02 Thread Léa Gris
Le 02/10/2021 à 15:09, Greg Wooledge écrivait : On Sat, Oct 02, 2021 at 01:41:35PM +0200, Léa Gris wrote: $ declare -f hello hello () { echo 'hello'; echo 'world' } The issue is that in some circumstances, newline characters may be handled as space, making the

Request change to output of declare -f funcname

2021-10-02 Thread Léa Gris
ld also control the verbosity/indentation for both the output of declare -p and declare -f -- Léa Gris

Re: efficient way to use matched string in variable substitution

2021-08-24 Thread Léa Gris
ble=SC2034 # shellcheck broken nameref usage check arr=("${BASH_REMATCH[@]:1}") } -- Léa Gris

Re: efficient way to use matched string in variable substitution

2021-08-24 Thread Léa Gris
Le 24/08/2021 à 14:06, Greg Wooledge écrivait : unicorn:~$ f6() { local i n=${#1} arr; for ((i=0; i See my featured version to also capture space and newlines: https://stackoverflow.com/a/68907322/7939871 -- Léa Gris

Re: efficient way to use matched string in variable substitution

2021-08-24 Thread Léa Gris
extglob # Split string characters into array IFS=' ' read -r -a array <<<"${n//?()/ }" # Debug print array declare -p array -- Léa Gris

Re: @K transformation

2021-08-20 Thread Léa Gris
ar" [2]="baz" [3]="qux") "${arr[@]@K}" expands into a single argument: 1. 0 "foo" 1 "bar" 2 "baz" 3 "qux" "${arr[@]@a}" expands into 4 argumsnts: 1. a 2. a 3. a 4. a Now @K would have been useful if it expanded into individual arguments for each entry rather than an eval expression. The @A suffers from the same weirdness expanding into an eval expression that actually duplicates the feature from declare -p. The @a expands the attribute from the container array for each element, which is as strange, because all array elements don't have attributes of their own. -- Léa Gris

Re: @K transformation

2021-08-20 Thread Léa Gris
Le 21/08/2021 à 00:06, Chet Ramey écrivait : On 8/19/21 6:37 AM, Léa Gris wrote: #!/usr/bin/env bash declare -A assoc=(   [P]=piano   [TB]='foldable table'   ['CH AIR']=chair ) options=("${assoc[@]@K}") The best way to clone an associative array is: d

Re: EPOCHREALTIME

2021-08-19 Thread Léa Gris
Le 19/08/2021 à 16:41, Eli Schwartz écrivait : On 8/19/21 9:41 AM, Léa Gris wrote: The error occurs, one would imagine, during the "convert string to float" stage, after parsing argv or forking to bc or whatever, but *before* passing it as an argument to printf(3). Here, bash is

Re: EPOCHREALTIME

2021-08-19 Thread Léa Gris
still use a dot, but the argument format's decimal separator is that of the system's locale. Imagine if C++ or Java had methods with different signature depending on system locale. You would scream fool. But for Bash, it was decided it was all fine. -- Léa Gris

Re: EPOCHREALTIME

2021-08-19 Thread Léa Gris
Han (LC_NUMERIC=C; echo "$EPOCHREALTIME") It will use a dot -- Léa Gris

Re: @K transformation

2021-08-19 Thread Léa Gris
@K}" shall have expanded into arguments and not expand quotes as string content. This would have made the @K expansion usable for dialog. Currently the associative array's key values pairs need be added to the options array in a for loop as: options=() for k in "${!assoc[@]}"; do options+=("$k" "${assoc[$k]}") done -- Léa Gris

feature request array expansion of keys values pairs and for k v loop

2021-08-18 Thread Léa Gris
lue would be a QOL over indexing and assigning the value with statement within the loop. Obviously it would fit equally well with associative arrays. -- Léa Gris

Re: Issue declaring an array via a variable name

2021-08-15 Thread Léa Gris
quot;me\" )" declare -g "$variable"'=( "world" "me" )' Be cautious with dynamic declare statements, because it is as insecure as eval. It will execute statements contained in variables. -- Léa Gris

Re: gettext feature request

2021-08-13 Thread Léa Gris
e: ```po #: a.sh:4 msgid "Hello World!" msgstr "Hallo Welt!" #: a.sh:7 msgid "String %1$q has %2$d characters\n" msgstr "%2$d Zeichen lang ist die Zeichenkette %1$q\n" ``` In default English, the output would be: ```none String Hello\ World\! has 12 characters ``` In German, the output would be: ```none 11 Zeichen lang ist die Zeichenkette Hallo\ Welt\! ``` -- Léa Gris

Re: gettext feature request

2021-07-24 Thread Léa Gris
aintain variable expansion outside the printf format string context to maintain backward compatibility. -- Léa Gris

Re: Crash on large brace expansion

2021-07-15 Thread Léa Gris
Le 15/07/2021 à 21:23, Greg Wooledge écrivait : On Thu, Jul 15, 2021 at 05:28:04PM +0200, Léa Gris wrote: Le 15/07/2021 à 16:36, Gabríel Arthúr Pétursson écrivait : Hi all, Executing the following results in a fierce crash: $ bash -c '{0..255}.{0..255}.{0..255}.{0..255}

Re: Crash on large brace expansion

2021-07-15 Thread Léa Gris
for ((c=0; c<=255; c++)); do for ((d=0; d<=255; d++)); do printf '%d.%d.%d.%d\n' "$a" "$b" "$c" "$d" done done done done -- Léa Gris

Re: [PATCH] Prefer non-gender specific pronouns

2021-06-07 Thread Léa Gris
istory and everyone has fought each-other. Then they will vanish and destroy other community, other history. -- Léa Gris

Re: Prefer non-gender specific pronouns

2021-06-06 Thread Léa Gris
ertoire HOME après connexion, ^^^ French "son" (his) is male because "répertoire" (directory) is male in French. User character's gender is not even mentioned. -- Léa Gris

Re: [PATCH] Prefer non-gender specific pronouns

2021-06-06 Thread Léa Gris
emand from cancel culture tenants. With all your clever carefulness in patching this. It remains a rewrite of history motivated by political reasons from a lobbying group of people spreading their damaging delusions everywhere. -- Léa Gris

Re: Prefer non-gender specific pronouns

2021-06-06 Thread Léa Gris
t remember that in normal people's grammar, "they" is a plural pronoun. -- Léa Gris

Re: Prefer non-gender specific pronouns

2021-06-05 Thread Léa Gris
non consensual, still heavily hot debated and politically loaded changes into technical projects like Bash. -- Léa Gris

Feature request: index of index

2021-05-06 Thread Léa Gris
declare -i last_index="42" It would be convenient to be able to index directly with this syntax: declare -i first_index=${!array[@]:0:1} declare -i last_index=${!array{@}: -1:1} -- Léa Gris

Bash development roadmap

2021-04-30 Thread Léa Gris
g tool you expect being on every systems, even older and no longer supported ones? -- Léa Gris

Re: Undocumented feature: Unnamed fifo '<(:)'

2021-04-08 Thread Léa Gris
/59e1b7e72462024b278652696f375e71 There is no need for bash specific features, although coproc and other fancynesses can help, these lack portability. -- Léa Gris

Re: is it a bug that \e's dont get escaped in declare -p output

2021-03-17 Thread Léa Gris
ut: declare -- escapestring=$'1\E[G\E[K2' declare -a escapearray=([0]=$'new \n line' [1]=$'and \E esc') declare -A assocarray=([$'1\E[G\E[K2']=$'and \E esc' [$'new \n line']=$'1\E[G\E[K2' ) declare -i intvar=42 declare -ai intarray=([0]="-42" [1]="666" [2]="555") declare -Ai intassoc=([$'1\E[G\E[K2']="456" [foo]="123" [bar]="789" ) declare -i nameref=42 -- Léa Gris OpenPGP_signature Description: OpenPGP digital signature

Re: is it a bug that \e's dont get escaped in declare -p output

2021-03-17 Thread Léa Gris
though this is just a question of QOL improvement, since the produced declare statement just works as-is. It is not user friendly but code friendly and compact if you use the declare -p foo bar baz >savedvars.sh for later include savedvars.sh -- Léa Gris OpenPGP_signature Description: OpenPGP digital signature

Re: Changing the way bash expands associative array subscripts

2021-03-15 Thread Léa Gris
rray[$key]}" printf '%s -> %s\n' "$key" "$value" done I'd love there would be more convergence when this is possible. -- Léa Gris OpenPGP_signature Description: OpenPGP digital signature

Re: Behaviour of test -v with assoc array and quote character in key

2021-02-23 Thread Léa Gris
nt that, and then copy it back into the array. Works, if you declare your associative array with A and i flags: ( LANG=C unset var assoc var=\'\] declare -Ai assoc assoc[$var]=1 assoc[$var]+=1 ((assoc['$var']++)) typeset -p assoc ) Output: declare -Ai assoc=(["']"]="3" ) -- Léa Gris

Assign read-only variables return code not usable inline

2021-02-23 Thread Léa Gris
t -p r Output: still there with $?=1, after: r=2 || exit 2 still there with $?=1, after: if ! r='hello'; then exit; fi declare -r r -- Léa Gris

Re: Behaviour of test -v with assoc array and quote character in key

2021-02-23 Thread Léa Gris
t -p assoc) bash: ']: syntax error: operand expected (error token is "']") but: $ (LANG=C; unset var assoc; var=\'\]; declare -A assoc; assoc[$var]=hello; typeset -p assoc) declare -A assoc=(["']"]="hello" ) -- Léa Gris

Re: export loses error

2021-02-08 Thread Léa Gris
. Kind of annoying, sure, but not a bug. https://mywiki.wooledge.org/BashPitfalls#local_var.3D.24.28cmd.29 vq Or this https://github.com/koalaman/shellcheck/wiki/SC2155 Nice helping shell linter would have warned of this pitfall. -- Léa Gris

Re: RFE: new syntax for command substitution to keep trailing newlines?

2021-01-27 Thread Léa Gris
character (formerly Ctrl + Z) that is unlikely to be part of a legit string: a=$(printf $'hello\n\n\n\32'); a=${a%$'\32'}; declare -p a -- Léa Gris

Re: Feature Request: scanf-like parsing

2021-01-25 Thread Léa Gris
the nice Bash feature is not an option anyway, and sometimes, yes eval will help. -- Léa Gris

Re: Feature Request: scanf-like parsing

2021-01-22 Thread Léa Gris
Le 22/01/2021 à 19:18, Léa Gris écrivait : Now replace the the () with {}, replace the implicit temporary fifo by and implicit temporary file; then have the same feature but without spawning a sub-shell. Instead of: tempfile=$(mktemp) || exit 1 trap 'rm -f "$tempfile"&#

Re: Feature Request: scanf-like parsing

2021-01-22 Thread Léa Gris
licit temporary file; then have the same feature but without spawning a sub-shell. -- Léa Gris

Re: Feature Request: scanf-like parsing

2021-01-22 Thread Léa Gris
be a temporary file in /tmp or /dev/shm rather-than a temporary named fifo as with < <(:). -- Léa Gris

Re: ${a:=b} expands to `b', not `a''s value

2021-01-20 Thread Léa Gris
Le 20/01/2021 à 13:51, Andreas Schwab écrivait : But that's not the value of the parameter. It is not, since at this point, the parameter has no value, the expansion expands the argument's value after ;= which is uppercase X here. -- Léa Gris

Re: ${a:=b} expands to `b', not `a''s value

2021-01-20 Thread Léa Gris
he fact that an expansion also assign a value is a questionable design choice though. If I had to use this I would just silence the expansion as an argument to the dummy true or : command : ${a:=X} Is this a bug or am I missing something here? Then likely not. -- Léa Gris

Re: echo $'\0' >a does not write the nul byte

2021-01-17 Thread Léa Gris
; echo '' echo "" are all equivalent, and none of them will output a null byte. The only way to output a null byte with shell built-in is: printf '\0' or non portable: echo -ne '\0' This is because `\0' is not a null byte or a nulll string but interpreted internally to the command to print a null byte. -- Léa Gris

Re: V+=1 doesn't work if V is a reference to an integer array element

2021-01-14 Thread Léa Gris
Le 14/01/2021 à 16:15, Chet Ramey écrivait : On 1/13/21 4:40 PM, Léa Gris wrote: Le 13/01/2021 à 22:13, Chet Ramey écrivait : The `-i' forces arithmetic evaluation, which makes this expand to the equivalent of `declare -n b=1'. That's an invalid name for a nameref, which you&#x

Re: V+=1 doesn't work if V is a reference to an integer array element

2021-01-13 Thread Léa Gris
-p a b; \ b+=2; \ declare -p a b Produces this output of the a array: declare -ai a=([0]="4") declare -in b="a[0]" declare -ai a=([0]="10") declare -in b="a[0]" I set the integer attribute to the nameref b after it has been assigned the "a[0]" string, so it keeps its string nameref value but is now also considered as an integer value. -- Léa Gris

Re: V+=1 doesn't work if V is a reference to an integer array element

2021-01-13 Thread Léa Gris
17(1)-release unset a b declare -ai a=(1) declare -in b="a[0]" declare -p a b declare -ai a=([0]="1") declare -in b="a[0]" b+=1 declare -p a declare -ai a=([0]="3") b+=1 declare -p a declare -ai a=([0]="7") b+=0 declare -p a declare -ai a=([0]="14") -- Léa Gris

Re: Associative array keys are not reusable in (( command

2021-01-11 Thread Léa Gris
Le 11/01/2021 à 15:42, Léa Gris écrivait : Declare an integer associative array instead: echo "$BASH_VERSION" 5.0.17(1)-release declare -Ai aa x='y[$(date >&2)0]' aa[$x]=1 declare -p aa declare -Ai aa=(["y[\$(date >&2)0]"]="1" ) aa[$

Re: Associative array keys are not reusable in (( command

2021-01-11 Thread Léa Gris
Declare an integer associative array instead: echo "$BASH_VERSION" 5.0.17(1)-release declare -Ai aa x='y[$(date >&2)0]' aa[$x]=1 declare -p aa declare -Ai aa=(["y[\$(date >&2)0]"]="1" ) aa[$x]+=1 declare -p aa declare -Ai aa=(["y[\$(date >&2)0]"]="2" ) -- Léa Gris

Re: declare accept + before =

2021-01-08 Thread Léa Gris
Le 08/01/2021 à 15:26, Chet Ramey écrivait : On 1/8/21 8:45 AM, Léa Gris wrote: Just curious why it accepts a + before = Try it with a variable that already has a value. OMG I feel stupid now! -- Léa Gris

declare accept + before =

2021-01-08 Thread Léa Gris
Just curious why it accepts a + before = unset a; declare a+=hello; typeset -p a bash, version 5.0.17(1)-release wrote: > declare -- a="hello" -- Léa Gris

Re: New Feature Request

2021-01-04 Thread Léa Gris
Le 04/01/2021 à 14:14, Greg Wooledge écrivait : It should be noted that $( var=$(ending the last line because it exactly a sub-shell shot syntax for var=$(cat file). Sub-shell $(commands list) output is always trimmed. -- Léa Gris

Re: 'Find' inside loop buggy, incorrectly make up dir.

2021-01-01 Thread Léa Gris
py or move files. -- Léa Gris

Re: Checking executability for asynchronous commands

2020-12-28 Thread Léa Gris
-shell background command, then shame on them. -- Léa Gris

Re: New Feature Request

2020-12-27 Thread Léa Gris
esources, Bash is a very bad choice. If you want to stay with scripting, as you already mentioned using Python; Python is a way better choice for dealing with the features and requirements you describes. -- Léa Gris

Re: [feature request] add associative array support to mapfile

2020-12-17 Thread Léa Gris
Le 17/12/2020 à 17:58, Léa Gris écrivait : Maybe (it is clearly open to discussion), the associative array mapping could be allowed to: - skip blank/comment only lines (1) - allow key without value - optionally trim trailing comment (1) Forgot about Bash built-in Regex engine: - allow using

Re: [feature request] add associative array support to mapfile

2020-12-17 Thread Léa Gris
Le 17/12/2020 à 17:35, Chet Ramey écrivait : One problem I see with it is that it assumes the introduction of word splitting into mapfile, with the burden on the user to ensure that there are exactly two resultant fields. It is just meant to be a replacement to looping on: IFS= read -r -d k v

Re: mapfile associative array shim Was: Re: [feature request] add associative array support to mapfile

2020-12-17 Thread Léa Gris
Shorty shim: ! { mapfile -A _/dev/null&&{ mapfile(){ local k v d=$'\n';local -n A=${*: -1:1};[ ${*: -2:1} = -A ]&&{ [ ${*:1:1} = -d ]&&d=${*:2:1};while read -rd "$d" k v||[[ -n $k && -n $v ]];do A[$k]=$v;done;:;}||command mapfile "$@";};} -- Léa Gris

mapfile associative array shim Was: Re: [feature request] add associative array support to mapfile

2020-12-17 Thread Léa Gris
} [[ ${*: -2:1} = -A ]] && { [[ ${*:1:1} = -d ]] && d=${*:2:1} while read -r -d "$d" k v || [[ -n $k && -n $v ]] do A[$k]=$v done true } || command mapfile "$@" } } Example usage: . mapfile_assoc_shim.bash IFS='=' mapfile -d '' -A assoc_null < <(kv_null_stream) -- Léa Gris

[feature request] add associative array support to mapfile

2020-12-17 Thread Léa Gris
mp; -n $v ]]; do assoc_null[$k]=$v done < <(kv_null_stream) declare -p assoc_null Expected output: declare -A assoc_cr=([key2]="value=2" [key1]="value1" ["key 3"]="value3" ) declare -A assoc_null=([key2]="value=2" [key1]="value1" [$'key\n3']="value3" ) -- Léa Gris

mysteries with the placeholder variable _

2020-12-12 Thread Léa Gris
r. - Dash seems to handle _ as a regular variable and accept assignment, which is probably conformant to POSIX shell specifications. -- Léa Gris

Re: No expansions performed while declaring an associative array using a list of keys and values

2020-12-11 Thread Léa Gris
3" ) What would have been so useful is expanding mapfile to associative arrays: key${IFS}value declare -A assoc IFS='= ' mapfile -t assoc <declare -A assoc(["key1"]="value1" ["key2"]="value2" ["key3"]=$'{\n "otherkey": "othervalue"\n}' -- Léa Gris

Re: No expansions performed while declaring an associative array using a list of keys and values

2020-12-11 Thread Léa Gris
key syntax that does not split a key variable: foo='1 2' declare -A bar=([$foo]=3 ) Or double square bracket tests: foo='1 2' [[ $foo == '1 2' ]] Did you try with?: # possibly originating read -a or mapfile declare -a foo=(1 2 ) # Declare associative array from key value array above declare -A assoc=("${foo[@]}" 3) -- Léa Gris

Variables declared in arithmetic expressions have no i flag

2020-11-24 Thread Léa Gris
typeset -p x > declare -- x="42624" unset x; declare -i x; ((x = 42)); x+=624; typeset -p x > declare -i x="666" -- Léa Gris

No longer receifing nntp feed from here

2020-11-17 Thread Léa Gris
Anyone to look why this is no longer connected to the bug-bash@gnu.org ML? -- Lea Gris

Re: use of set -e inside parenthesis and conditionnal second command

2020-11-17 Thread Léa Gris
ropriately straight exit without any cleanup or fallback. This feature deserves a bold disclaimer to think twice before using it rather than explicit error handing. -- Léa Gris

Re: [ping] declare -c still undocumented.

2020-11-13 Thread Léa Gris
he lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRU address@hiddenhttp://cnswww.cns.cwru.edu/~chet/ -- Léa Gris

[ping] declare -c still undocumented.

2020-11-12 Thread Léa Gris
at-By: run declare -c Fix: document in bash(1), document in usage:, add to builtin help. -- Léa Gris OpenPGP_0x70946F168078ED52.asc Description: application/pgp-keys OpenPGP_signature Description: OpenPGP digital signature

Lack of documentation about mapfile callback

2020-02-08 Thread Léa Gris
man bash.1 > When callback is evaluated, it is supplied the index of the next > array element to be assigned and the line to be assigned to that > element as additional arguments. callback is evaluated after the > line is read but before the array element is assigned. I can not find real-life im

Re: Two states of empty arrays

2019-12-12 Thread Léa Gris
Le 12/12/2019 à 20:13, Chet Ramey écrivait : >> # Empty array declared without parenthesis >> unset myArr >> declare -a myArr >> typeset -p myArr >> echo "${#myArr[@]}" > > This is an unset variable with the array attribute; you have not assigned a > value. >> # Empty array declared without paren

Two states of empty arrays

2019-12-12 Thread Léa Gris
declare -a myArr=() typeset -p myArr echo "${#myArr[@]}" output: declare -a myArr=() 0 What is the reason for having different states for empty arrays? -- Lea Gris -- Léa Gris signature.asc Description: OpenPGP digital signature

Two states of empty arryays

2019-12-12 Thread Léa Gris
Hello, Depending on how an empty array is declared, it is not stored with the same state. # Empty array declared without parenthesis unset myArr declare -a myArr typeset -p myArr echo "${#myArr[@]}" output: declare -a myArr 0 # Empty array declared without parenthesis unset myArr declare -a myA

  1   2   >