> On 25 Oct 2016, at 05:40, Martijn Dekker wrote:
>
> Op 25-10-16 om 00:42 schreef Stuart Shelton:
>> Failing this, is there any alternative to ‘typeset’ to list a
>> variable declared as local to a function but which has not yet been
>> assigned a value?
>
> Try simply testing the exit status
What version of bash are you using Stuart? typeset -p should work for
local variables too in any recent bash version.
> On 25 Oct 2016, at 17:36, Eduardo Bustamante wrote:
>
> What version of bash are you using Stuart? typeset -p should work for
> local variables too in any recent bash version.
typeset omitting existing variables or failing and causing a SIGPIPE I’ve seen
with Ubuntu 14.04 LTS’ bash-4.3.11(1)
Ah! You're right. The second issue was already reported back in 2015
https://lists.gnu.org/archive/html/bug-bash/2015-02/msg00060.html
Now, regarding the SIGPIPE issue. The message bash is printing just
means that grep closed the pipe, so the bash process receives a
SIGPIPE when attempting to writ
Stuart Shelton wrote:
I have some code which evals a configuration file - but before doing so
attempts to validate the content. It does this by taking each potential
keyword from the file and then doing:
if typeset -p | grep -q "^declare -. ${var}$”; then
… to determine whether the keyword
> On 25 Oct 2016, at 20:45, L. A. Walsh wrote:
> Stuart Shelton wrote:
>> I have some code which evals a configuration file - but before doing so
>> attempts to validate the content. It does this by taking each potential
>> keyword from the file and then doing:
>>
>> if typeset -p | grep -q "
Stuart Shelton wrote:
The cases appear, purely by inspection, to be:
Not declared: trivially, `typeset -p` doesn’t include the value;
Declared (even as local) but unassigned: `typeset -p` includes "declare --
varname";
Declared and assigned: `typeset -p` includes "declare -- varname=‘value’”
Op 25-10-16 om 18:19 schreef Stuart Shelton:
> However, it doesn’t appear to be able to detect local variables (is this
> intentional or a bug?):
Strange. Works for me on bash 3.2.57 and bash 4.4.0 (Mac OS X) and bash
4.2.53 and 4.1.17 (Linux).
- M.