@@ -166,11 +166,27 @@ type Cmd struct {
166
166
// value in the slice for each duplicate key is used.
167
167
// As a special case on Windows, SYSTEMROOT is always added if
168
168
// missing and not explicitly set to the empty string.
169
+ //
170
+ // See also the Dir field, which may set PWD in the environment.
169
171
Env []string
170
172
171
173
// Dir specifies the working directory of the command.
172
174
// If Dir is the empty string, Run runs the command in the
173
175
// calling process's current directory.
176
+ //
177
+ // On Unix systems, the value of Dir also determines the
178
+ // child process's PWD environment variable if not otherwise
179
+ // specified. A Unix process represents its working directory
180
+ // not by name but as an implicit reference to a node in the
181
+ // file tree. So, if the child process obtains its working
182
+ // directory by calling a function such as C's getcwd, which
183
+ // computes the canonical name by walking up the file tree, it
184
+ // will not recover the original value of Dir if that value
185
+ // was an alias involving symbolic links. However, if the
186
+ // child process calls Go's [os.Getwd] or GNU C's
187
+ // get_current_dir_name, and the value of PWD is an alias for
188
+ // the current directory, those functions will return the
189
+ // value of PWD, which matches the value of Dir.
174
190
Dir string
175
191
176
192
// Stdin specifies the process's standard input.
0 commit comments