Skip to content

Commit 4ec1885

Browse files
committed
doc: notice for shell expansions for cargo add/remove
1 parent fc18f76 commit 4ec1885

File tree

8 files changed

+41
-2
lines changed

8 files changed

+41
-2
lines changed

src/doc/man/cargo-add.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ Add as a [build dependency](../reference/specifying-dependencies.html#build-depe
8181

8282
{{#option "`--target` _target_" }}
8383
Add as a dependency to the [given target platform](../reference/specifying-dependencies.html#platform-specific-dependencies).
84+
85+
To avoid unexpected shell expansions, you may use quotes around each target, e.g., `--target 'cfg(unix)'`.
8486
{{/option}}
8587

8688
{{/options}}
@@ -166,5 +168,9 @@ Add dependencies to only the specified package.
166168

167169
cargo add serde serde_json -F serde/derive
168170

171+
5. Add `windows` as a platform specific dependency on `cfg(windows)`
172+
173+
cargo add windows --target 'cfg(windows)'
174+
169175
## SEE ALSO
170176
{{man "cargo" 1}}, {{man "cargo-remove" 1}}

src/doc/man/cargo-remove.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Remove as a [build dependency](../reference/specifying-dependencies.html#build-d
3030

3131
{{#option "`--target` _target_" }}
3232
Remove as a dependency to the [given target platform](../reference/specifying-dependencies.html#platform-specific-dependencies).
33+
34+
To avoid unexpected shell expansions, you may use quotes around each target, e.g., `--target 'cfg(unix)'`.
3335
{{/option}}
3436

3537
{{/options}}

src/doc/man/generated_txt/cargo-add.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ OPTIONS
7676
Add as a dependency to the given target platform
7777
<https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies>.
7878

79+
To avoid unexpected shell expansions, you may use quotes around each
80+
target, e.g., --target 'cfg(unix)'.
81+
7982
Dependency options
8083
--dry-run
8184
Don’t actually write the manifest
@@ -224,5 +227,10 @@ EXAMPLES
224227

225228
cargo add serde serde_json -F serde/derive
226229

230+
5. Add windows as a platform specific dependency on cfg(windows)
231+
232+
cargo add windows --target 'cfg(windows)'
233+
227234
SEE ALSO
228235
cargo(1), cargo-remove(1)
236+

src/doc/man/generated_txt/cargo-remove.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ OPTIONS
2323
Remove as a dependency to the given target platform
2424
<https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies>.
2525

26+
To avoid unexpected shell expansions, you may use quotes around each
27+
target, e.g., --target 'cfg(unix)'.
28+
2629
Miscellaneous Options
2730
--dry-run
2831
Don’t actually write to the manifest.

src/doc/src/commands/cargo-add.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ which is defined by the <code>registry.default</code> config key which defaults
8686

8787

8888
<dt class="option-term" id="option-cargo-add---target"><a class="option-anchor" href="#option-cargo-add---target"></a><code>--target</code> <em>target</em></dt>
89-
<dd class="option-desc">Add as a dependency to the <a href="../reference/specifying-dependencies.html#platform-specific-dependencies">given target platform</a>.</dd>
89+
<dd class="option-desc">Add as a dependency to the <a href="../reference/specifying-dependencies.html#platform-specific-dependencies">given target platform</a>.</p>
90+
<p>To avoid unexpected shell expansions, you may use quotes around each target, e.g., <code>--target 'cfg(unix)'</code>.</dd>
9091

9192

9293
</dl>
@@ -269,5 +270,9 @@ details on environment variables that Cargo reads.
269270

270271
cargo add serde serde_json -F serde/derive
271272

273+
5. Add `windows` as a platform specific dependency on `cfg(windows)`
274+
275+
cargo add windows --target 'cfg(windows)'
276+
272277
## SEE ALSO
273278
[cargo(1)](cargo.html), [cargo-remove(1)](cargo-remove.html)

src/doc/src/commands/cargo-remove.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Remove one or more dependencies from a `Cargo.toml` manifest.
2929

3030

3131
<dt class="option-term" id="option-cargo-remove---target"><a class="option-anchor" href="#option-cargo-remove---target"></a><code>--target</code> <em>target</em></dt>
32-
<dd class="option-desc">Remove as a dependency to the <a href="../reference/specifying-dependencies.html#platform-specific-dependencies">given target platform</a>.</dd>
32+
<dd class="option-desc">Remove as a dependency to the <a href="../reference/specifying-dependencies.html#platform-specific-dependencies">given target platform</a>.</p>
33+
<p>To avoid unexpected shell expansions, you may use quotes around each target, e.g., <code>--target 'cfg(unix)'</code>.</dd>
3334

3435

3536
</dl>

src/etc/man/cargo-add.1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ Add as a \fIbuild dependency\fR <https://doc.rust\-lang.org/cargo/reference/spec
9696
\fB\-\-target\fR \fItarget\fR
9797
.RS 4
9898
Add as a dependency to the \fIgiven target platform\fR <https://doc.rust\-lang.org/cargo/reference/specifying\-dependencies.html#platform\-specific\-dependencies>\&.
99+
.sp
100+
To avoid unexpected shell expansions, you may use quotes around each target, e.g., \fB\-\-target 'cfg(unix)'\fR\&.
99101
.RE
100102
.SS "Dependency options"
101103
.sp
@@ -307,5 +309,15 @@ cargo add serde serde_json \-F serde/derive
307309
.fi
308310
.RE
309311
.RE
312+
.sp
313+
.RS 4
314+
\h'-04' 5.\h'+01'Add \fBwindows\fR as a platform specific dependency on \fBcfg(windows)\fR
315+
.sp
316+
.RS 4
317+
.nf
318+
cargo add windows \-\-target 'cfg(windows)'
319+
.fi
320+
.RE
321+
.RE
310322
.SH "SEE ALSO"
311323
\fBcargo\fR(1), \fBcargo\-remove\fR(1)

src/etc/man/cargo-remove.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Remove as a \fIbuild dependency\fR <https://doc.rust\-lang.org/cargo/reference/s
2525
\fB\-\-target\fR \fItarget\fR
2626
.RS 4
2727
Remove as a dependency to the \fIgiven target platform\fR <https://doc.rust\-lang.org/cargo/reference/specifying\-dependencies.html#platform\-specific\-dependencies>\&.
28+
.sp
29+
To avoid unexpected shell expansions, you may use quotes around each target, e.g., \fB\-\-target 'cfg(unix)'\fR\&.
2830
.RE
2931
.SS "Miscellaneous Options"
3032
.sp

0 commit comments

Comments
 (0)