Skip to content

Commit

Permalink
Update variables_and_subexpressions.md (nushell#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
WindSoilder authored Oct 18, 2022
1 parent 65a6215 commit 845b6ef
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions book/variables_and_subexpressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,25 @@ The `where size > 10kb` is a command with two parts: the command name [`where`](
```

For short-hand syntax to work, the column name must appear on the left-hand side of the operation (like `size` in `size > 10kb`).

## Subexpressions with external commands
You may find something strange when you're using subexpression with external commands, for example:

```
> echo $"my pwd is (pwd), hooray!"
```

And nu gives you the following output:

```
my pwd is /private/tmp
, hooray!
```

That's because when you execute `(pwd)`, it yields to `/private/tmp\n`, and the value is inserted into our string, so the raw string will be `my pwd is /private/tmp\n, hooray!`, and then `\n` is a newline character. A work around can be put `str trim` after external command, like this:

```
> echo $"my pwd is (pwd | str trim), hooray!"
```

Then everything will be normal.

0 comments on commit 845b6ef

Please sign in to comment.