Skip to content

Conversation

@xtaran
Copy link

@xtaran xtaran commented Aug 10, 2022

Brackets are shell wildcard special characters and if there are no files 301 or 302 in the current directory, the command hc 30[12] will fail if e.g. bash's shell option failglob is set:

$  hc 30[12]
bash: no match: 30[12]

Even worse: Independent of that shell option this command will yield different outcomes depending which files or directories exist in the current directory:

$ hc 30[12]
Status code 301
Message: Moved Permanently
Code explanation: Object moved permanently -- see URI list

Status code 302
Message: Found
Code explanation: Object moved temporarily -- see URI list

$ touch 302
$ hc 30[12]
Status code 302
Message: Found
Code explanation: Object moved temporarily -- see URI list

$

The proper fix is to quote the argument containing the brackets.

Brackets are shell wildcard special characters and if there are no files `301` or `302` in the current directory, the command `hc 30[12]` will fail if e.g. bash's shell option `failglob` is set:

```
$  hc 30[12]
bash: no match: 30[12]
```

Even worse: Independent of that shell option this command will yield different outcomes depending which files or directories exist in the current directory:

```
$ hc 30[12]
Status code 301
Message: Moved Permanently
Code explanation: Object moved permanently -- see URI list

Status code 302
Message: Found
Code explanation: Object moved temporarily -- see URI list

$ touch 302
$ hc 30[12]
Status code 302
Message: Found
Code explanation: Object moved temporarily -- see URI list

$
```

The proper fix is to quote the argument containing the brackets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant