Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16394

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

Path csiph.com!tncsrv06.tnetconsulting.net!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From beluro@web.de
Newsgroups gnu.bash.bug
Subject Re: hash -l with empty hash table prints to stdout
Date Wed, 17 Jun 2020 05:07:31 +0200
Lines 41
Approved bug-bash@gnu.org
Message-ID <mailman.2033.1592363265.2541.bug-bash@gnu.org> (permalink)
References <bd77214b-2690-f5de-a814-108e5be8b6f1@case.edu> <87o8pi4eya.fsf@hobgoblin.ariadne.com> <20200617030731.GA21555@jar>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
X-Trace usenet.stanford.edu 1592363266 16526 209.51.188.17 (17 Jun 2020 03:07:46 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org, chet.ramey@case.edu
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1592363256; bh=vOcrNoSbjJYlpVUaCqesNs6pJYyGylPqKnqKOi5VvAY=; h=X-UI-Sender-Class:Date:From:To:Subject:References:In-Reply-To; b=gmNZq1TLGLMGZo8dHiVOFVT+wgHngh3XCXGm1YWW+iqTv9TqjLkj6QtqOYnZhEmy1 6hm8enLHPaC9L5RhYpoVWLEOla6QLREigBaB9AtYEfYhU3L4wBHQJ/9EKk/PdSS1UT NHbsB1xMDUfe1bplIyp59voXX4fISsKkC9wTL9s0=
X-UI-Sender-Class c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9
Content-Disposition inline
In-Reply-To <87o8pi4eya.fsf@hobgoblin.ariadne.com>
User-Agent Mutt/1.10.1 (2018-07-13)
X-Provags-ID V03:K1:udCi+bo1DUtzHkWjenMUc6g75HBWhfM9ctvCAobL4pxsDlosJ+b xQzwC84h+5h5kL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Zb9SwmhPfxYUq9ak 36D/C3agtIqK/rfJqUvDsn3S13eQ4RRgi9WxZV0OVt6mUmpTwhjrlwSJ3EJBuJ7Bh4u6af7dB Yr9BDMEl/LQOOYoIHKbSnWOKpnl+TkGfsRft39rR2kTWC7h/ZACLzGQgOXoyXdhac1kcnNWbA f7P/GUxJqxY/05CRyvbRvBY/eklH7/CLKRWAqLQPuPErsZTc+EviZ0zrj1vpGUZRbYfz9cLq4 SaAGanj1UVAioV2MLXaOIPGDb6zsn5kVi/rWENSgHvmJBUsxFQMauKfHfb896GmnDximH2zBU M6Ea61DBV00wXY+vXl3jrJXxePojLQuNU2Do4k8ZqSAlaLutcC6B5JlmQSzKrXhZpjD9U=
Received-SPF pass client-ip=212.227.15.4; envelope-from=beluro@web.de; helo=mout.web.de
X-detected-operating-system by eggs.gnu.org: First seen = 2020/06/16 23:07:38
X-ACL-Warn Detected OS = Linux 2.2.x-3.x [generic]
X-Spam_score_int -27
X-Spam_score -2.8
X-Spam_bar --
X-Spam_report (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <20200617030731.GA21555@jar>
X-Mailman-Original-References <bd77214b-2690-f5de-a814-108e5be8b6f1@case.edu> <87o8pi4eya.fsf@hobgoblin.ariadne.com>
Xref csiph.com gnu.bash.bug:16394

Show key headers only | View raw


> You might want to temporarily enable posix mode, which suppresses the
> message.

Good to know. For scripts intended to be sourced, this would include testing
for posix mode first, then enable posix mode, run `hash -l', then maybe re-
disable it, but ok.

Maybe adopt the POSIX-mode behaviour? Does the user need this message at all?

> Maybe you could make the empty message be a comment?
>
> $ hash -l
> # hash: hash table empty

That, too, would be totally acceptable IMO, and be somewhat analogous to
`bind -p'.

Another solution might be to only print a message if stdout is a terminal.
That sounds slightly horrifying to me, though probably would do "the right
thing" in pretty much every situation, I guess.

I looked for the pattern "re-?us" in the `help <builtin>' outputs and the bash
man page to find builtins where similar questions arise and found `alias -p',
`bind -X', and `complete' (likewise, `complete -p') which all do not output
anything in comparable situations, indicating success. (If `alias -p' gave
output "There are no aliases" if there are none, that'd be comparable to the
`hash -l' situation, IMO, etc).

I didn't manage to make the output of `bind -p', `bind -v', `readonly -p',
`set' and `umask -p' logically empty (maybe there are compile-time
configurations or setups/systems making this possible).

`shopt' doesn't appear to have an option for giving output re-usable as
input (?).

The output of `enable -p' is logically non-empty as long as there is anything
enabled, and I don't know if there's some hackery to access the enable
builtin after having disabled it (`enable -n enable' is a dead-end, I think),
so the question of whether to output an explanatory message about an otherwise
empty output probably doesn't arise here, too.

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: hash -l with empty hash table prints to stdout beluro@web.de - 2020-06-17 05:07 +0200

csiph-web