From: David Kastrup <dak@gnu.org>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: "Jeremiah Mahler" <jmmahler@gmail.com>,
git@vger.kernel.org, "Jeff King" <peff@peff.net>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Caleb Thompson" <cjaysson@gmail.com>
Subject: Re: [PATCH v3 2/5] commit test: Change $PWD to $(pwd)
Date: Tue, 27 May 2014 09:35:30 +0200 [thread overview]
Message-ID: <87sinv3c8t.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <53843206.3040902@viscovery.net> (Johannes Sixt's message of "Tue, 27 May 2014 08:34:46 +0200")
Johannes Sixt <j.sixt@viscovery.net> writes:
> That said, it is not wrong to use $(pwd) with test_set_editor, it's just
> unnecessarily slow.
Any shell that knows $(...) is pretty sure to have pwd as a built-in.
I don't think Git will run on those kind of ancient shells reverting to
/bin/pwd here.
The autoconf manual (info "(autoconf) Limitations of Builtins") states
'pwd'
With modern shells, plain 'pwd' outputs a "logical" directory name,
some of whose components may be symbolic links. These directory
names are in contrast to "physical" directory names, whose
components are all directories.
Posix 1003.1-2001 requires that 'pwd' must support the '-L'
("logical") and '-P' ("physical") options, with '-L' being the
default. However, traditional shells do not support these options,
and their 'pwd' command has the '-P' behavior.
Portable scripts should assume neither option is supported, and
should assume neither behavior is the default. Also, on many hosts
'/bin/pwd' is equivalent to 'pwd -P', but Posix does not require
this behavior and portable scripts should not rely on it.
Typically it's best to use plain 'pwd'. On modern hosts this
outputs logical directory names, which have the following
advantages:
* Logical names are what the user specified.
* Physical names may not be portable from one installation host
to another due to network file system gymnastics.
* On modern hosts 'pwd -P' may fail due to lack of permissions
to some parent directory, but plain 'pwd' cannot fail for this
reason.
Also please see the discussion of the 'cd' command.
So $PWD is pretty much guaranteed to be the same as $(pwd) and pretty
much guaranteed to _not_ be "unnecessarily slow" when not run in an
inner loop.
However, looking at (info "(autoconf) Special Shell Variables") I see
'PWD'
Posix 1003.1-2001 requires that 'cd' and 'pwd' must update the
'PWD' environment variable to point to the logical name of the
current directory, but traditional shells do not support this.
This can cause confusion if one shell instance maintains 'PWD' but
a subsidiary and different shell does not know about 'PWD' and
executes 'cd'; in this case 'PWD' points to the wrong directory.
Use '`pwd`' rather than '$PWD'.
Ok, probably Git relies on Posix 1003.1-2001 in other respects so it's
likely not much of an actual issue.
--
David Kastrup
next prev parent reply other threads:[~2014-05-27 7:35 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-25 6:24 [PATCH v2] commit: support commit.verbose and --no-verbose Caleb Thompson
2014-05-25 7:02 ` Jeremiah Mahler
2014-05-25 7:44 ` Jeremiah Mahler
2014-05-25 8:44 ` Duy Nguyen
2014-05-25 10:23 ` Eric Sunshine
2014-05-26 18:56 ` [PATCH v3 0/5] " Caleb Thompson
2014-05-26 18:56 ` [PATCH v3 1/5] commit test: Use test_config instead of git-config Caleb Thompson
2014-05-26 18:56 ` [PATCH v3 2/5] commit test: Change $PWD to $(pwd) Caleb Thompson
2014-05-27 5:46 ` Johannes Sixt
2014-05-27 6:10 ` Eric Sunshine
2014-05-27 6:14 ` Jeremiah Mahler
2014-05-27 6:34 ` Johannes Sixt
2014-05-27 7:35 ` David Kastrup [this message]
2014-05-26 18:56 ` [PATCH v3 3/5] commit test: Use write_script Caleb Thompson
2014-05-27 22:30 ` Eric Sunshine
2014-05-27 22:42 ` Junio C Hamano
2014-05-26 18:56 ` [PATCH v3 4/5] commit test: test_set_editor in each test Caleb Thompson
2014-05-27 22:59 ` Eric Sunshine
2014-05-26 18:56 ` [PATCH v3 5/5] commit: support commit.verbose and --no-verbose Caleb Thompson
2014-05-26 20:33 ` Jeremiah Mahler
2014-05-26 20:47 ` Caleb Thompson
[not found] ` <CA+g4mq8iGNVm-2Uj8j2bJLDazaTS_U76BO9-jeS9Aw4RZnki5A@mail.gmail.com>
2014-05-26 21:00 ` Jeremiah Mahler
2014-05-26 22:14 ` Jeremiah Mahler
2014-05-26 22:34 ` [PATCH v3 0/5] " Jeremiah Mahler
2014-05-26 22:40 ` Caleb Thompson
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=87sinv3c8t.fsf@fencepost.gnu.org \
--to=dak@gnu.org \
--cc=cjaysson@gmail.com \
--cc=git@vger.kernel.org \
--cc=j.sixt@viscovery.net \
--cc=jmmahler@gmail.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.