bug-bash
[Top][All Lists]
Advanced

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

coproc and existing variables


From: Grisha Levit
Subject: coproc and existing variables
Date: Thu, 21 Apr 2016 03:36:04 -0400

A few issues inspired by the coproc proposal in this thread: http://lists.gnu.org/archive/html/bug-bash/2016-04/msg00050.html

1. coproc unsets readonly NAME after the process completes

$ declare -p UID; coproc UID { :; }; wait; declare -p UID
declare -ir UID="501"
bash: UID: readonly variable
bash: UID: readonly variable
[1] 60652
[1]+  Done                    coproc UID { :; }
bash: declare: UID: not found

2. Segfault if NAME is an existing associative array

$ declare -A A; coproc A { :; }

0   bash                           0x0000000100e61075 hash_search + 53 (hashlib.c:141)
1   bash                           0x0000000100e6bf74 assoc_insert + 36 (assoc.c:77)
2   bash                           0x0000000100e6a8a7 bind_array_var_internal + 87 (arrayfunc.c:183)
3   bash                           0x0000000100e34619 coproc_setvars + 121 (execute_cmd.c:2173)
4   bash                           0x0000000100e2fb52 execute_command_internal + 738 (execute_cmd.c:2281)
5   bash                           0x0000000100e30e07 execute_command_internal + 5527 (execute_cmd.c:2562)
6   bash                           0x0000000100e2f809 execute_command + 137 (execute_cmd.c:405)
7   bash                           0x0000000100e1c986 reader_loop + 662 (eval.c:180)
8   bash                           0x0000000100e1bc15 main + 6709 (shell.c:610)

3. If NAME is $,?,@, etc, bash will create a new array variable with that name.  This zeroth index of this array variable will then take precedence over the real variable in some contexts

$ echo ${@:0}; coproc @ { sleep 1; }; echo ${@:0}
-bash
[1] 72037
61

reply via email to

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