1PWD(1P)                    POSIX Programmer's Manual                   PWD(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       pwd — return working directory name
14

SYNOPSIS

16       pwd [−L|−P]
17

DESCRIPTION

19       The pwd utility shall write to standard output an absolute pathname  of
20       the current working directory, which does not contain the filenames dot
21       or dot-dot.
22

OPTIONS

24       The pwd utility  shall  conform  to  the  Base  Definitions  volume  of
25       POSIX.1‐2008, Section 12.2, Utility Syntax Guidelines.
26
27       The following options shall be supported by the implementation:
28
29       −L        If the PWD environment variable contains an absolute pathname
30                 of the current directory that does not contain the  filenames
31                 dot  or  dot-dot,  pwd  shall write this pathname to standard
32                 output. Otherwise, if the PWD environment variable contains a
33                 pathname  of  the  current  directory  that  is  longer  than
34                 {PATH_MAX} bytes including  the  terminating  null,  and  the
35                 pathname does not contain any components that are dot or dot-
36                 dot, it is unspecified whether pwd writes  this  pathname  to
37                 standard output or behaves as if the −P option had been spec‐
38                 ified. Otherwise, the  −L  option  shall  behave  as  the  −P
39                 option.
40
41       −P        The pathname written to standard output shall not contain any
42                 components that refer to files  of  type  symbolic  link.  If
43                 there are multiple pathnames that the pwd utility could write
44                 to standard output, one beginning with a single <slash> char‐
45                 acter  and one or more beginning with two <slash> characters,
46                 then it shall write the  pathname  beginning  with  a  single
47                 <slash>  character. The pathname shall not contain any unnec‐
48                 essary <slash>  characters  after  the  leading  one  or  two
49                 <slash> characters.
50
51       If  both  −L and −P are specified, the last one shall apply. If neither
52       −L nor −P is specified, the pwd utility shall behave as if −L had  been
53       specified.
54

OPERANDS

56       None.
57

STDIN

59       Not used.
60

INPUT FILES

62       None.
63

ENVIRONMENT VARIABLES

65       The following environment variables shall affect the execution of pwd:
66
67       LANG      Provide  a  default  value for the internationalization vari‐
68                 ables that are unset or null. (See the Base Definitions  vol‐
69                 ume  of POSIX.1‐2008, Section 8.2, Internationalization Vari‐
70                 ables the precedence of internationalization  variables  used
71                 to determine the values of locale categories.)
72
73       LC_ALL    If  set  to  a non-empty string value, override the values of
74                 all the other internationalization variables.
75
76       LC_MESSAGES
77                 Determine the locale that should be used to affect the format
78                 and  contents  of  diagnostic  messages  written  to standard
79                 error.
80
81       NLSPATH   Determine the location of message catalogs for the processing
82                 of LC_MESSAGES.
83
84       PWD       An  absolute pathname of the current working directory. If an
85                 application sets or unsets the value of PWD, the behavior  of
86                 pwd is unspecified.
87

ASYNCHRONOUS EVENTS

89       Default.
90

STDOUT

92       The  pwd  utility output is an absolute pathname of the current working
93       directory:
94
95           "%s\n", <directory pathname>
96

STDERR

98       The standard error shall be used only for diagnostic messages.
99

OUTPUT FILES

101       None.
102

EXTENDED DESCRIPTION

104       None.
105

EXIT STATUS

107       The following exit values shall be returned:
108
109        0    Successful completion.
110
111       >0    An error occurred.
112

CONSEQUENCES OF ERRORS

114       If an error is detected, output shall not be written to  standard  out‐
115       put,  a  diagnostic message shall be written to standard error, and the
116       exit status is not zero.
117
118       The following sections are informative.
119

APPLICATION USAGE

121       If the pathname obtained from pwd is longer than {PATH_MAX}  bytes,  it
122       could  produce an error if passed to cd.  Therefore, in order to return
123       to that directory it may be necessary to break the pathname  into  sec‐
124       tions  shorter than {PATH_MAX} and call cd on each section in turn (the
125       first section being an absolute pathname and subsequent sections  being
126       relative pathnames).
127

EXAMPLES

129       None.
130

RATIONALE

132       Some  implementations have historically provided pwd as a shell special
133       built-in command.
134
135       In most utilities, if an error occurs, partial output may be written to
136       standard  output. This does not happen in historical implementations of
137       pwd.  Because pwd is frequently used in historical shell scripts  with‐
138       out  checking  the  exit  status,  it  is important that the historical
139       behavior is required here; therefore, the CONSEQUENCES OF  ERRORS  sec‐
140       tion  specifically  disallows any partial output being written to stan‐
141       dard output.
142
143       An earlier version of this standard stated  that  the  PWD  environment
144       variable was affected when the −P option was in effect. This was incor‐
145       rect; conforming implementations do not do this.
146

FUTURE DIRECTIONS

148       None.
149

SEE ALSO

151       cd
152
153       The Base Definitions volume of  POSIX.1‐2008,  Chapter  8,  Environment
154       Variables, Section 12.2, Utility Syntax Guidelines
155
156       The System Interfaces volume of POSIX.1‐2008, getcwd()
157
159       Portions  of  this text are reprinted and reproduced in electronic form
160       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
161       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
162       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
163       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
164       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
165       event of any discrepancy between this version and the original IEEE and
166       The Open Group Standard, the original IEEE and The Open Group  Standard
167       is  the  referee document. The original Standard can be obtained online
168       at http://www.unix.org/online.html .
169
170       Any typographical or formatting errors that appear  in  this  page  are
171       most likely to have been introduced during the conversion of the source
172       files to man page format. To report such errors,  see  https://www.ker
173       nel.org/doc/man-pages/reporting_bugs.html .
174
175
176
177IEEE/The Open Group                  2013                              PWD(1P)
Impressum