Skip to content

Commit 0945b74

Browse files
committed
document the platform-specific behavior of Command::current_dir
1 parent 1558ae7 commit 0945b74

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libstd/process.rs

+10
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,14 @@ impl Command {
626626

627627
/// Sets the working directory for the child process.
628628
///
629+
/// # Platform-specific behavior
630+
///
631+
/// If the program path is relative (e.g. `"./script.sh"`), it's ambiguous
632+
/// whether it should be interpreted relative to the parent's working
633+
/// directory or relative to `current_dir`. The behavior in this case is
634+
/// platform specific and unstable, and it's recommended to use
635+
/// [`canonicalize`] to get an absolute program path instead.
636+
///
629637
/// # Examples
630638
///
631639
/// Basic usage:
@@ -638,6 +646,8 @@ impl Command {
638646
/// .spawn()
639647
/// .expect("ls command failed to start");
640648
/// ```
649+
///
650+
/// [`canonicalize`]: ../fs/fn.canonicalize.html
641651
#[stable(feature = "process", since = "1.0.0")]
642652
pub fn current_dir<P: AsRef<Path>>(&mut self, dir: P) -> &mut Command {
643653
self.inner.cwd(dir.as_ref().as_ref());

0 commit comments

Comments
 (0)