bug-bash
[Top][All Lists]
Advanced

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

Re: hash -l with empty hash table prints to stdout


From: Eli Schwartz
Subject: Re: hash -l with empty hash table prints to stdout
Date: Tue, 16 Jun 2020 22:38:51 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

On 6/16/20 10:13 PM, Dale R. Worley wrote:
> What a weird problem!  Yes, "hash -l" should produce output that can be
> read by bash.  But sending the "bash: hash table empty" message to
> stderr put you in the situation where "hash -l >file" doesn't really
> leave the output of "hash -l" in "file".  

Of course it would. The output of hash -l would be "bash-parseable code
to recreate the hash table", as in fact is currently documented. And
*diagnostic* messages are not output, and should not be treated as
output, and don't belong in that file one way or another.

If one really, truly wanted to collect both the expected output *and*
the diagnostic messages, one could redirect stderr too... but I don't
foresee this as being a problem. ;) People would be more likely to
redirect it to /dev/null.

> Maybe you could make the empty
> message be a comment?
> 
>     $ hash -l
>     # hash: hash table empty
> 
> That is acceptable input for bash, has the right effect when read by
> bash, is human-readable, and is capturable by redirecting stdout.

As I suggested, yes. :)

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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