|
96 | 96 | //! run_cmd!(du -ah $dir | sort -hr | head -n 10)?;
|
97 | 97 | //!
|
98 | 98 | //! // or a group of commands
|
99 |
| -//! // if any command fails, just return Err(...) |
| 99 | +//! // if any command fails, just return Err(...), which is similar to bash's `set -euo pipefail` |
100 | 100 | //! let file = "/tmp/f";
|
101 | 101 | //! let keyword = "rust";
|
102 | 102 | //! run_cmd! {
|
|
114 | 114 | //!
|
115 | 115 | //! ```
|
116 | 116 | //! # use cmd_lib::run_fun;
|
117 |
| -//! let version = run_fun!(rustc --version)?; |
| 117 | +//! let version = run_fun!(rustc --version | awk r"{print $2}")?; |
118 | 118 | //! eprintln!("Your rust version is {}", version);
|
119 | 119 | //!
|
120 | 120 | //! // with pipes
|
|
369 | 369 | //! - [std::env::set_var] and [std::env::remove_var] **[must not be called]** in a multi-threaded program
|
370 | 370 | //! - [`tls_init!`](https://docs.rs/cmd_lib/latest/cmd_lib/macro.tls_init.html),
|
371 | 371 | //! [`tls_get!`](https://docs.rs/cmd_lib/latest/cmd_lib/macro.tls_get.html), and
|
372 |
| -//! [`tls_set!`](https://docs.rs/cmd_lib/latest/cmd_lib/macro.tls_set.html) create *thread-local* variables, which |
373 |
| -//! means each thread will have its own independent version of the variable |
| 372 | +//! [`tls_set!`](https://docs.rs/cmd_lib/latest/cmd_lib/macro.tls_set.html) create *thread-local* variables, which means |
| 373 | +//! each thread will have its own independent version of the variable |
374 | 374 | //! - [`set_debug`](https://docs.rs/cmd_lib/latest/cmd_lib/fn.set_debug.html) and
|
375 | 375 | //! [`set_pipefail`](https://docs.rs/cmd_lib/latest/cmd_lib/fn.set_pipefail.html) are *global* and affect all threads;
|
376 |
| -//! there is currently no way to change those settings without affecting other threads |
| 376 | +//! to change those settings without affecting other threads, use |
| 377 | +//! [`ScopedDebug`](https://docs.rs/cmd_lib/latest/cmd_lib/struct.ScopedDebug.html) and |
| 378 | +//! [`ScopedPipefail`](https://docs.rs/cmd_lib/latest/cmd_lib/struct.ScopedPipefail.html) |
377 | 379 | //!
|
378 | 380 | //! [std::env::set_var]: https://doc.rust-lang.org/std/env/fn.set_var.html
|
379 | 381 | //! [std::env::remove_var]: https://doc.rust-lang.org/std/env/fn.remove_var.html
|
|
0 commit comments