blob: 8e187c72042da255dd8130c06b80c4575299b3ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
---
tags:
- bash
---
[[Bash]] [[Globbing patterns]]
---
See https://www.shellcheck.net/wiki/SC2086
issue with building a command-line and prevent globbing by quoting parameter expansion, solution: use array.
```
#!/usr/bin/env bash
function test() {
echo "${@}"
}
function blaat() {
local flags
test hello "${flags[@]}"
}
function blaat1() {
local flags
flags=(a b c)
test hello "${flags[@]}"
}
blaat
blaat1
```
```
❯ bash /tmp/tmp.qI8lPlBQUe
hello
hello a b c
```
|