help-bash
[Top][All Lists]
Advanced

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

Re: Why does a shell script need current directory?


From: Peng Yu
Subject: Re: Why does a shell script need current directory?
Date: Sat, 13 Feb 2021 20:17:31 -0600

> The part of the paragraph that you omitted makes it pretty clear
> that a value of PWD inherited in the environment must correspond
> to the current working directory (which necessarily has to exist)
> to be considered.  Even then, there are many cases in which the
> shell has license to ignore it.

I have to say the POSIX manual is confusing. According to the
following text, if PWD is specified from the environment, does shell
have to check the absolute pathname of the current working directory?

"""
If a value for PWD is passed to the shell in the environment when it
is executed, the value is an absolute pathname of   the current
working directory that is no longer than {PATH_MAX} bytes including
the terminating null byte, and the value does not contain any
components that are dot or dot-dot, then the shell shall set PWD to
the value from the environment.
"""

If so, this doesn't make too much sense. If the shell needs to check
the absolute path of the current working directory anyway, why does it
bother whether PWD is specified in the environment. It seems that this
double requirement is either unnecessary, or I misunderstood
something.

-- 
Regards,
Peng



reply via email to

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