Dash Archive mirror
 help / color / mirror / Atom feed
From: Christoph Anton Mitterer <calestyo@scientia.org>
To: dash@vger.kernel.org
Subject: incomplete documentation of local?
Date: Sun, 20 Nov 2022 05:57:42 +0100	[thread overview]
Message-ID: <3c3c3df0f7b172a9a1befceccd18c7e71fa91ee9.camel@scientia.org> (raw)

Hey.

I noticed two things in dash’s "local" which seem to be missing from
dash’s manpage:


1) Like bash’s, dash’s local seem to support:
   local foo=bar
   which doesn't seem to be mentioned in the manpage.

   I guess many people nevertheless use this (with dash), so it should
   either be documented as working, or as something one cannot rely on
   in the future.


2) There is no clear documentation about "local"’s exit status.
   The section describing it doesn’t say anything and it doesn’t seem
   to follow from other sections, e.g. "Command Exit Status" says
   merely:
   > Additionally, the builtin commands return exit
   > codes, as does an executed shell function.

   This is especially important as dash’s local seems to do the
   something similar than e.g. bash’s, and return 0 unless used outside
   of a function or on some invalid variable name (e.g. "$").

   However, it does not fail, when called on a readonly variable.

   The main problem of this not being documented is IMO, that people
   may easily be tempted that:
     local foo="$(somecommmand)"
     rc="$?"
   works like:
     foo="$(somecommmand)"
     rc="$?"
   and gives back the exit status of somecommand, which it does not.


I could provide a patch with some wording if that helps.


Thanks,
Chris.

             reply	other threads:[~2022-11-20  4:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-20  4:57 Christoph Anton Mitterer [this message]
2022-11-20  5:16 ` incomplete documentation of local? Christoph Anton Mitterer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3c3c3df0f7b172a9a1befceccd18c7e71fa91ee9.camel@scientia.org \
    --to=calestyo@scientia.org \
    --cc=dash@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).