a=(["\$(echo foo)"]="1" [foo]="3" )
> declare -A a=([foo]="3" )
> declare -A a=()
As I've observed, in single expansion mode, unset will fail to unset a
value when the key has a closing bracket in it. Perhaps unset should
check the last character first when looking for the closing bracket.
Tested in 5.1.4.
--
konsolebox
separate from the first class
syntax. Bash is not C or Go and shouldn't be written like it.
--
konsolebox
On Fri, Apr 2, 2021 at 2:56 AM Chet Ramey wrote:
>
> On 4/1/21 2:55 PM, konsolebox wrote:
>
> > So to keep compatibility, would this be the right way?
> >
> > if [[ BASH_VERSINFO -ge 6 || BASH_VERSINFO -eq 5 && BASH_VERSINFO -ge 2 ]];
> >
On Fri, Apr 2, 2021 at 3:02 AM konsolebox wrote:
>
> On Fri, Apr 2, 2021 at 2:56 AM Chet Ramey wrote:
> >
> > On 4/1/21 2:55 PM, konsolebox wrote:
> >
> > > So to keep compatibility, would this be the right way?
> > >
> > > if [[ BASH_VERSINFO
t; rule.
>
> The right question would be why '} else' works.
Indeed. This inconsistency should be fixed and prevent people from
using it wrong. `}; else` should work but not `} else` just like how
`{ :; } :` doesn't.
--
konsolebox
reserved words themselves just like () and {} as they can be
used multi-line but they aren't allowed to be adjacent to else et al
without a semicolon. [[ ]], (( )), {}, and () are practically just
commands with first-class parsing that consistently have to end with a
semicolon if followed by another reserved word or command.
--
konsolebox
with them as well. This should have been explicitly allowed by the
shell. It's highly doable even if they are followed with
non-keywords. Just look at awk's syntax.
--
konsolebox
2150. They are labeled as "Reserved words".
--
konsolebox
s like this does the same:
# echo a | tee /dev/fd/4 4>/dev/tcp/host/port
# echo a | ( tee /dev/fd/4 ) 4>/dev/tcp/host/port
The workaround is to use process substitution and cat:
# echo a | tee >( cat > /dev/tcp/host/port )
Tested in 5.1.4.
--
konsolebox
gt;/dev/tcp/host/port'
Nice strategies.
--
konsolebox
doesn't generate that error on macOS, for instance, which has /dev/fd.
Thanks. I'll take note of it for future reference.
--
konsolebox
le functions to have less versions.
The detection of unbound variables seem to have become more reasonable
since 5.0 and I hope it gets improved further. I don't use set -u in
older bash and it's only for development mode.
--
konsolebox
On Mon, Apr 5, 2021 at 9:44 PM Chet Ramey wrote:
>
> On 4/1/21 3:02 PM, konsolebox wrote:
>
> >> To do what, exactly?
> >
> > To keep this working in both behaviors.
> >
> > declare -A a
> > key='$(echo foo)'
> > a[$key]=1
> &
On Tue, Apr 6, 2021 at 9:57 PM Alex fxmbsw7 Ratchev wrote:
>
> arr=( ) implies no [0]=
arr[0] is not exactly being referenced here.
--
konsolebox
On Tue, Apr 6, 2021 at 9:57 PM Alex fxmbsw7 Ratchev wrote:
>
> arr=( ) implies no [0]=
Also `arr=()` does not imply `arr[0]=`. `arr[0]` remains unset and not
assigned to any. Not even an empty string.
--
konsolebox
verything or nothing. Unbound variable errors should not apply to it.
--
konsolebox
d don't expand the
referenced target themselves.
${!__ref} is synonymous to ${array[@]}, not ${${array[@]}}.
This is why you can do other parameter expansion features like
${!var+.} ${!var@a}.
--
konsolebox
of the arguments of the `unset' builtin is the cleanest way
> to solve the problem of `key=@; unset -v a[$key]'.
Or maybe just completely avoid this new behaviors and allow another
way to unset an element of an array.
a[$key]=()
a[@]=()
I think a shell already does this. Not sure if it's from ksh, zsh, or pdksh.
--
konsolebox
On Wed, Apr 7, 2021 at 12:20 AM Ilkka Virta wrote:
> What konsolebox said about a[$k]=() works in my Zsh for indexed arrays, but
> not associative ones.
> (It replaces an array slice, so can also be used to insert elements in the
> middle.)
Bash can adopt this. Also if Bash coul
the clearest example I can give
is Java's LinkedHashMap.
--
konsolebox
On Wed, Apr 7, 2021 at 9:25 PM Chet Ramey wrote:
>
> On 4/5/21 4:45 PM, konsolebox wrote:
> > set -u
> > array=()
> > __ref=array[@]
> > : "${array[@]}" # Reports nothing
>
> This is a special case, mirroring the special case that POSIX carved
rrayref = 1;
+ }
+}
+ else if (valid_array_reference (name, 0))
{
int qflags;
char *t;
--
konsolebox
On Fri, Apr 9, 2021 at 2:19 AM Chet Ramey wrote:
> What is your end goal? To run the same script on different versions of
> bash, or something else?
Nevermind. I overthinked.
--
konsolebox
On Fri, Apr 9, 2021 at 3:21 AM Chet Ramey wrote:
>
> On 4/6/21 11:42 AM, konsolebox wrote:
>
> > Or maybe just completely avoid this new behaviors and allow another
> > way to unset an element of an array.
> >
> > a[$key]=()
> > a[@]=()
>
> While thi
king internal sanity checks.
--
konsolebox
On Fri, Apr 9, 2021 at 8:17 AM konsolebox wrote:
> It's a definite shell feature despite lacking internal sanity checks.
*despite having limited
--
konsolebox
my_function {
local my_function__a
another_function my_function__a
}
This solution applies to namerefs, indirections and evil eval.
Keeping the passed references sane is up to the scripter.
--
konsolebox
s or external commands is a function.
Try `type which`.
--
konsolebox
ak scripts.
The only change I'd want is have `unset 'a[@]'` only unset the
elements and not the array itself.
--
konsolebox
On Fri, Apr 16, 2021 at 12:10 AM Chet Ramey wrote:
> > I actually agree with konsolebox that assoc_expand_once for unset
> > shouldn't be defaulted. The option `assoc_expand_once' is incomplete
> > in the sense that the behavior of `a[@]' and `a[*]' are
t going to go that way without much better reasons than I've seen
> so far.
There's less reason to choose a complicated solution that adds
thinking overhead, adds inconsistencies and breaks scripts.
Making unset skip default word expansion on tokens that pass
valid_array_reference () is much simpler.
--
konsolebox
also available in
https://github.com/konsolebox/bash/tree/skip_expansion_of_valid_array_refs_in_unset.
The patch is applied against the latest commit (f3a35a2d60) in master
branch. The changes can be conveniently compared in
https://git.io/JOgrE.
The solution allows the following tests to pass. A
aval = (char *)xmalloc (1);
aval[0] = '\0'; /* like do_assignment_internal */
- free_aval = 1;
}
bind_assoc_var_internal (var, h, akey, aval, flags);
- if (free_aval)
- free (aval);
+ free (aval);
}
}
--
konsolebox
unsigned int flags; /* Flags associated with this word. */
> `y.tab.c' is automatically generated from `parse.y'. You should edit
> `parse.y' instead of `y.tab.c'
I also modified parse.y. All changes made so far can be seen in
https://git.io/JOam0.
Thanks for the tips.
--
konsolebox
I'll just skip that as I would also have to modify
other declarations for consistency. I think the code is already good
enough for a proof of concept at least.
--
konsolebox
global variable when unsetting an
iterator in an initialization script to keep the variables clean, even
just by theory.
--
konsolebox
On Fri, Apr 30, 2021 at 4:09 PM Robert Elz wrote:
>
> Date:Fri, 30 Apr 2021 14:53:58 +0800
> From:konsolebox
> Message-ID:
>
>
> | {{ }} - Similar to { }, but runs like a function so variables can be
> | declared local
>
> From
utocomplete the commands that are accepted.
Perhaps adding a shell option that enables this or another option to
read like -E would be sensible.
--
konsolebox
On Tue, May 25, 2021 at 4:36 AM Chet Ramey wrote:
>
> On 5/22/21 8:29 AM, konsolebox wrote:
> > `read -e` doesn't recognize custom completions (at least on my basic
> > observations). For example, if I enable `complete -IW 'someword
> > another-word'`,
On Wed, Jun 2, 2021, 10:27 konsolebox, wrote:
> On Tue, May 25, 2021 at 4:36 AM Chet Ramey wrote:
> >
> > On 5/22/21 8:29 AM, konsolebox wrote:
> > > `read -e` doesn't recognize custom completions (at least on my basic
> > > observations). For exampl
n't spaces are also passed as an
argument and stored in COMP_WORDS. This surprised me a bit, and I
think it would be helpful if this behavior gets documented as well.
Tested with 5.1.12.
--
konsolebox
t appearing in the completions.
--
konsolebox
Nevermind I found a way. The trick is to enable nospace by default
and add space manually to only result when result is 1 and is valid.
--
konsolebox
nce on how a separator is kept
like rl_special_prefixes but none of them seems to have anything to do
with the space character.
--
konsolebox
On Fri, Dec 17, 2021 at 7:13 PM Chet Ramey wrote:
>
> On 12/17/21 2:00 PM, konsolebox wrote:
> > On Sat, Dec 18, 2021, 00:49 Chet Ramey, wrote:
> >> Well, the documentation says the line gets broken into words the way
> >> readline does it, and r
ociative array
variable that can contain the name of the completion as the key and
the value as the word break characters.
--
konsolebox
On Wed, Dec 22, 2021 at 4:07 AM Greg Wooledge wrote:
> I would recommend not using set -u.
> Especially
> when you need to support multiple bash versions, or even multiple shells.
It's still useful during development stages.
--
konsolebox
ds to be documented. It makes
use of a single parameter but interprets its values differently.
Anyway at least I now know the behavior is intended, so I don't really
mind how this goes.
--
konsolebox
To Chet: Any thoughts on this?
--
konsolebox
cripts more portable, which means other
> implementors
> are under no pressure to copy the feature...Implemented optimisations
> for the standard shell syntax simply work, and improve performance, while
> still allowing the script to work anywhere.
>
I'm not really concerned about portability for this. Bash has always made
its own fruitful implementations.
--
konsolebox
On Thu, Apr 8, 2021, 06:56 konsolebox, wrote:
> On Thu, Apr 8, 2021 at 2:44 AM Chet Ramey wrote:
> > Indirection does not check whether or not the variable it's indirecting
> > is $@/$* or ${array[@/*]}. It simply goes by the return value.
>
> It looks like it can
On Mon, Jun 21, 2021, 23:34 Chet Ramey, wrote:
> On 6/16/21 2:04 AM, konsolebox wrote:
>
> > Thanks, that worked well. Is there a chance a feature that would
> > allow this be defaulty implemented in the next version? If yes, what
> > would be the strategy
On Thu, Dec 30, 2021 at 4:35 PM Chet Ramey wrote:
>
> On 12/27/21 11:37 PM, konsolebox wrote:
> > On Thu, Apr 8, 2021, 06:56 konsolebox, > <mailto:konsole...@gmail.com>> wrote:
> >
> > On Thu, Apr 8, 2021 at 2:44 AM Chet Ramey >
ogether with Chet's and Greg's mail; All around good and
> reasonable things said by people I trust to say sensible things about
> the shell. Thanks. I'll stand down from my "you need to do something
> right now" position.
>
> Take care,
>
As for me whatever it is, it should be done consistently and with no
compromise. No matter how "slightly broken" it is or no matter unlikely it
is to occur it should be fixed. Post filename expansion or population
processes should not make any interpretation of the expanded filenames in
whatsoever manner.
--
konsolebox
On Tue, Jan 25, 2022, 06:24 Robert Elz, wrote:
> Date:Tue, 25 Jan 2022 05:45:23 +0800
> From: konsolebox
> Message-ID: <
> cajnmqwbvrbdijqcu8+oo0gvic7onew8nkv4djfyy3o5eepm...@mail.gmail.com>
>
> | As for me whatever it is, it should be done
ta that is needed.
> That would be reasonable, the \x nonsense (the PSx escapes) aren't.
Thanks for the details. I at least agree with not using \w and \W
here if anyone wants to escape literal escape sequences, or wait till
bash adds a generous feature that escapes any valid terminal code.
--
konsolebox
On Thu, Dec 30, 2021 at 4:35 PM Chet Ramey wrote:
> Let's try it. Thanks for the report.
It seems to be already fixed in 5.2-alpha (thanks), but I can't see it
mentioned in the changelog. Can you kindly confirm if it really is?
--
konsolebox
On Mon, Feb 7, 2022, 00:31 Chet Ramey, wrote:
> From CHANGES:
>
> ...
Well I'm glad. Thanks again!
--
konsolebox
ns it and exits well.
Compiling it with a safer flag like `-ggdb3 -O -pipe` didn't help.
--
konsolebox
Commonly `readarray -t`, a pipe, and a subshell is used to get the
results of compgen but this has two problems:
- It uses a pipe and a subshell
- Values having newlines will be split
Those can be prevented if another option is added. E.g.:
compgen -O array_var ...
--
konsolebox
be properly quoted, this manual quoting hacks wouldn't be needed.
--
konsolebox
lash to the result when the result matches a
directory. For example, "test" which refers to a task becomes
"test/".
--
konsolebox
On Fri, Feb 25, 2022 at 8:29 AM konsolebox wrote:
> What I need more is an option that allows replacing the current
> word including the quote (', ", or $') that begins it with the result
> as is rather than appending the result to the quote.
... because the result is alr
On Fri, Feb 25, 2022 at 2:46 PM Chet Ramey wrote:
>
> On 2/25/22 3:29 AM, konsolebox wrote:
> > On Mon, Feb 21, 2022 at 4:32 PM Chet Ramey wrote:
> >> What does `properly quoted' mean here and how does it differ from the
> >> quoting you get when you force c
On Mon, Mar 7, 2022, 23:16 Chet Ramey, wrote:
> On 2/26/22 2:01 PM, konsolebox wrote:
>
> > I think an option like 'escape' that simply escapes COMPREPLY
> > values when used for completion and doesn't compare it to existing
> > filesystem objects will be
ckspace to be typed to be triggered. I can't
reproduce it with 5.1.4 and 5.1.16. All tested versions have their
bundled readlines compiled with them.
--
konsolebox
On Mon, Mar 21, 2022 at 7:11 PM Chet Ramey wrote:
> Isn't this the same as
>
> https://lists.gnu.org/archive/html/bug-readline/2022-02/msg00038.html ?
>
> That's already fixed.
I'm sorry I didn't check. Yes it's already fixed.
--
konsolebox
On Sat, Feb 19, 2022 at 9:34 PM Chet Ramey wrote:
> Thanks for the report. This is the result of needing to clean up parser
> state before recursively calling it to parse the command substitution.
Just tested devel. This one's fixed as well.
--
konsolebox
ction name is same as script) or
'utils..' since the dot is allowed in Bash. For the
global variables used in each script, I have them all capitalized and
prefixed with the name of the "namespace", like
"UTILS__". It risks conflict with global and builtin
variables but adds easy distinguishability vs. just using lowercase
letters prefixed with an underscore. Optionally an underscore can be
prefixed to avoid the conflict but I haven't really needed it so far
besides on a few shared (just, probably) ones.
I also do have an extended "include" function that accepts wildcards
best used for loading dynamic yet managed sub-scripts.
--
konsolebox
This doesn't look right to me:
# export BASH_ARGV0=fdsafasfas
# bash
# echo "$BASH_ARGV0|$0"
fdsafasfas|fdsafasfas
# echo $BASH_VERSION
5.2.0(1)-release
--
konsolebox
On Mon, Jun 21, 2021 at 11:34 PM Chet Ramey wrote:
> I'll consider it. It's low priority right now.
Hello Chet, I just saw this implemented in 5.3. Just want to say
thanks a lot!! I extremely appreciate it.
--
konsolebox
On Mon, Feb 21, 2022 at 2:23 AM konsolebox wrote:
>
> Commonly `readarray -t`, a pipe, and a subshell is used to get the
> results of compgen but this has two problems:
>
> - It uses a pipe and a subshell
> - Values having newlines will be split
>
> Those can be preven
Hi. Is there a way to prevent this segmentation fault in Bash? I'm not sure
where the fault happens but when there's a function that handles a trap and
when a signal is caught during a session of read with -t, Bash crashes. An
example code that makes this happen is this:
#!/b
at 12:28 AM, Chet Ramey wrote:
> On 1/24/13 8:35 AM, konsolebox wrote:
> > Hi. Is there a way to prevent this segmentation fault in Bash? I'm not
> sure
> > where the fault happens but when there's a function that handles a trap
> and
> > when a signal is cau
>
> This doesn't help a lot. How about building bash-4.2.42 with -g so
> debugging symbols are preserved, then seeing where the crash is?
>
I compiled 4.2.42 using gcc 4.6.3 (C[XX]FLAGS="-march=native -O2 -g"). It
took longer before the crash occurred and this is the report I got:
malloc: ./read
> OK. What version of Linux are you using? Maybe I have that and will be
> able to reproduce it more easily.
>
> Chet
>
Gentoo, but it happens in Slackware as well. Ubuntu too I think.
> OK. What version of Linux are you using? Maybe I have that and will be
> able to reproduce it more easily.
>
> Chet
>
Oh sorry, if you mean the kernel version it's 3.4.10-tuxonice in Gentoo but
it happens in most if not all kernels I used.
Glibc version is 2.15-r2.
I really appreciate that. Thank you very much :)
My software would finally work in a loop with no worries.
OK, I was able to figure it out. The problem is that the `read -t'
> generates SIGALRM, which sometimes arrives and is handled while the SIGCHLD
> trap is running (bash-4.2 runs the SIGCHLD
Hi. I made a post on this before but I haven't got a reply. I actually want
to know what people think about the idea as I actually find a command like
this really helpful. Anyone please?
On Wed, Feb 6, 2013 at 11:30 AM, konsolebox wrote:
> Hi. I was wondering if we could add a builtin
On Thu, Apr 4, 2013 at 3:26 PM, Dan Douglas wrote:
> On Wednesday, April 03, 2013 11:53:48 PM konsolebox wrote:
> > Hi. I made a post on this before but I haven't got a reply. I actually
> want
> > to know what people think about the idea as I actually find a command
>
> Another "feature" of this kind of construct is that you can put the name
> of the variable-to-be-assigned into another variable:
>
> ptr=some_variable
> setvalue "$ptr" "$foo"
>
> Which may be a good thing or a bad thing, but either way it's definitely
> a thing that someone will (ab)use if it'
On Thu, Apr 4, 2013 at 8:51 PM, konsolebox wrote:
> Another "feature" of this kind of construct is that you can put the name
>> of the variable-to-be-assigned into another variable:
>>
>> ptr=some_variable
>> setvalue "$ptr" "$foo"
>&
On Thu, Apr 4, 2013 at 9:21 PM, Greg Wooledge wrote:
> imadev:~$ stuffit() { declare -n array="$1"; array[thing]=foobar; }
Checked my test script and I actually added -A to declare in the process
sorry. It's working now thanks.
Ross
/ci/377ccc3307bdb617ecdc4643acbde5329001e0b3/tree/source/assume.sh
http://sourceforge.net/p/playshell/code/ci/377ccc3307bdb617ecdc4643acbde5329001e0b3/tree/source/log.sh
This we could do if we have a builtin-level function.
On Thu, Apr 4, 2013 at 8:51 PM, konsolebox wrote:
> Another "fe
On Mon, Apr 8, 2013 at 9:05 PM, Greg Wooledge wrote:
> On Fri, Apr 05, 2013 at 09:15:10AM +0800, konsolebox wrote:
> > The only thing left here is that we can't have error control like when we
> > are to create generally shared library scripts e.g.:
> >
It's actually simple with trap. Just catch SIGINT with a function and call
a function to kill the tree:
https://www.linuxquestions.org/questions/blog/konsolebox-210384/bash-functions-to-list-and-kill-or-send-signals-to-process-trees-34624/
Note killtree3. And that could be merged as one s
problem.
I thought I should just say this just in case you did used them.
Ross
On Wed, Apr 10, 2013 at 9:00 PM, konsolebox wrote:
> It's actually simple with trap. Just catch SIGINT with a function and call
> a function to kill the tree:
>
>
> https://www.linuxquestions.o
Good day,
It seems like starting 4.3 (beta2) bash already delays handling traps until
read exits. Is this intended? It would be a problem if read has a long
timeout or doesn't have a timeout at all:
wait
done
And the trap is always called every after 5 seconds when input already
times out:
sleeping.
reading.
caught.
--
waiting.
sleeping.
reading.
caught.
--
waiting.
sleeping.
reading.
...
Cheers, konsolebox
On Fri, Oct 11, 2013 at 2:47 PM, konsolebox wrote:
> Good day,
>
>
e-key input there's an easy workaround with it
through loops with 1-second interval which doesn't really affect my program
but it would be a problem to scripts that read user input line by line.
SIGCHLD is really a very useful signal so I hope it would be reconsidered.
Cheers, konsolebox
On Mon, Oct 14, 2013 at 2:29 AM, Chet Ramey wrote:
> On 10/11/13 6:19 PM, konsolebox wrote:
> > On Fri, Oct 11, 2013 at 10:06 PM, Chet Ramey > <mailto:chet.ra...@case.edu>> wrote:
> >
> > The SIGCHLD handler was particularly bad, since children can die
On Wed, Feb 19, 2014 at 11:01 PM, Chet Ramey wrote:
> On 2/19/14 1:51 AM, konsolebox wrote:
>
> > Bash-4.3 handles signals and traps when a read run by the read
> builtin is
> > interrupted by a signal. I'm not sure that's the best thing to do,
> >
Just added correction:
On Mon, Mar 3, 2014 at 8:47 PM, konsolebox wrote:
> echo "Interacting."
>
> until read -t 1; do
> continue
> done
>
I actually modified that part as well. Results are similar even if not in a
loop:
echo "Interacting."
>
>
y but through the said functions.
I hope the development team will also consider adding a way in bash to
declare global variables inside a function perhaps either with an
option in typeset or declare like -g (same as zsh) and/or a builtin
function like global as similar to local.
Cheers,
konsolebox
just
refers to expanding a variable.
An official note in this mailing list that it won't change if intended
may also help.
Cheers,
konsolebox
On Wed, Jul 18, 2018 at 5:19 AM, Grisha Levit wrote:
> $ set -u; unset var; f() { test -v 'var[0]'; echo $?; }; var[0]=X f
> 0
> -bash: var[0]: unbound variable
I'm not getting this error. What version of bash are you using?
--
konsolebox
gt; the `parameter' in ${[!]parameter[op[word]]}. If you think it would read
> more clearly if I used `parameter' instead of `variable', I can look at
> doing that.
I just saw the update in the devel branch. Thanks a lot!
--
konsolebox
/konsolebox/bash/tree/assoc_array_brace_assign.
Besides having an easy way to define associative arrays, this feature
would also allow associative arrays to be used as "return variables".
The caller wouldn't have to initialize the associative array unless it
wants to have it declared l
On Tue, Jul 31, 2018 at 10:31 PM, Chet Ramey wrote:
> On 7/27/18 7:13 PM, konsolebox wrote:
>> Hi Chet,
>>
>> I wonder if you can allow bash to have another syntax to allow simpler
>> declaration and/or definition of associative arrays. The changes
>> needed t
]] && enable sleep
I have patch attached as file, and also uploaded in
https://github.com/konsolebox/bash/tree/builtin_sleep.
--
konsolebox
commit 14203764a208279d213d2b4c0babf52abca6078b
Author: konsolebox
Date: Sun Jul 29 07:58:32 2018 +0800
Add sleep as a static builtin that is dis
1 - 100 of 216 matches
Mail list logo