9218 |
The use of @samp{break 2}, etcetera, is safe. |
The use of @samp{break 2}, etcetera, is safe. |
9219 |
|
|
9220 |
|
|
9221 |
@item @command{cd} and @command{pwd} |
@item @command{cd} |
9222 |
@c --------------------------------- |
@c --------------------------------- |
9223 |
@prindex @command{cd} |
@prindex @command{cd} |
9224 |
@prindex @command{pwd} |
@acronym{POSIX} 1003.1-2001 requires that @command{cd} must support |
9225 |
@acronym{POSIX} 1003.1-2001 requires that @command{cd} and |
the @option{-L} (``logical'') and @option{-P} (``physical'') options, |
|
@command{pwd} must support the @option{-L} and @option{-P} options, |
|
9226 |
with @option{-L} being the default. However, traditional shells do |
with @option{-L} being the default. However, traditional shells do |
9227 |
not support these options, and their @command{cd} and @command{pwd} |
not support these options, and their @command{cd} command has the |
9228 |
commands have the @option{-P} behavior. |
@option{-P} behavior. |
9229 |
|
|
9230 |
Portable scripts should assume neither option is supported, and should |
Portable scripts should assume neither option is supported, and should |
9231 |
assume neither behavior is the default. This can be a bit tricky, |
assume neither behavior is the default. This can be a bit tricky, |
9232 |
since the @acronym{POSIX} default behavior means that, for example, |
since the @acronym{POSIX} default behavior means that, for example, |
9233 |
@samp{ls ..} and @samp{cd ..} may refer to different directories. It |
@samp{ls ..} and @samp{cd ..} may refer to different directories if |
9234 |
is safe to use @command{cd @var{dir}} if @var{dir} contains no |
the current logical directory is a symbolic link. It is safe to use |
9235 |
@file{..} components. Also, Autoconf-generated scripts check for this |
@command{cd @var{dir}} if @var{dir} contains no @file{..} components. |
9236 |
problem when computing variables like @code{ac_top_srcdir} |
Also, Autoconf-generated scripts check for this problem when computing |
9237 |
(@pxref{Configuration Actions}), so it is safe to @command{cd} to |
variables like @code{ac_top_srcdir} (@pxref{Configuration Actions}), |
9238 |
these variables. |
so it is safe to @command{cd} to these variables. |
9239 |
|
|
9240 |
|
Also please see the discussion of the @command{pwd} command. |
9241 |
|
|
9242 |
|
|
9243 |
@item @command{case} |
@item @command{case} |
9467 |
|
|
9468 |
@item @command{pwd} |
@item @command{pwd} |
9469 |
@c ---------------- |
@c ---------------- |
9470 |
See @command{cd} above. |
@prindex @command{pwd} |
9471 |
|
With modern shells, plain @command{pwd} outputs a ``logical'' |
9472 |
|
directory name, some of whose components may be symbolic links. These |
9473 |
|
directory names are in contrast to ``physical'' directory names, whose |
9474 |
|
components are all directories. |
9475 |
|
|
9476 |
|
@acronym{POSIX} 1003.1-2001 requires that @command{pwd} must support |
9477 |
|
the @option{-L} (``logical'') and @option{-P} (``physical'') options, |
9478 |
|
with @option{-L} being the default. However, traditional shells do |
9479 |
|
not support these options, and their @command{pwd} command has the |
9480 |
|
@option{-P} behavior. |
9481 |
|
|
9482 |
|
Portable scripts should assume neither option is supported, and should |
9483 |
|
assume neither behavior is the default. Also, on many hosts |
9484 |
|
@samp{/bin/pwd} is equivalent to @samp{pwd -P}, but @acronym{POSIX} |
9485 |
|
does not require this behavior and portable scripts should not rely on |
9486 |
|
it. |
9487 |
|
|
9488 |
|
Typically it's best to use plain @command{pwd}. On modern hosts this |
9489 |
|
outputs logical directory names, which have the following advantages: |
9490 |
|
|
9491 |
|
@itemize @bullet |
9492 |
|
@item |
9493 |
|
Logical names are what the user specified. |
9494 |
|
@item |
9495 |
|
Physical names may not be portable from one installation |
9496 |
|
host to another due to network filesystem gymnastics. |
9497 |
|
@item |
9498 |
|
On modern hosts @samp{pwd -P} may fail due to lack of permissions to |
9499 |
|
some parent directory, but plain @command{pwd} cannot fail for this |
9500 |
|
reason. |
9501 |
|
@end itemize |
9502 |
|
|
9503 |
|
Also please see the discussion of the @command{cd} command. |
9504 |
|
|
9505 |
|
|
9506 |
@item @command{set} |
@item @command{set} |
9507 |
@c ---------------- |
@c ---------------- |