Commit 00afc99
authored
Update file existence checks in goostats.sh
The `-a` option for `if` does not work in all environments. I have tested the script below in three different environments, Git Bash, MobaXTerm and RedHat Linux and they all produce the following output:
# The Script
```
#!/bin/bash
touch checkForfile.md
echo WITH -a
if [ -a checkForfile.md ]; then echo yes; else echo no;fi
if [ -a NocheckForfile.md ]; then echo yes; else echo no;fi
echo WITH ! -a
if [ ! -a checkForfile.md ]; then echo no; else echo yes;fi
if [ ! -a NocheckForfile.md ]; then echo no; else echo yes;fi
echo WITH -e
if [ -e checkForfile.md ]; then echo yes; else echo no;fi
if [ -e NocheckForfile.md ]; then echo yes; else echo no;fi
echo WITH ! -e
if [ ! -e checkForfile.md ]; then echo no; else echo yes;fi
if [ ! -e NocheckForfile.md ]; then echo no; else echo yes;fi
echo WITH -f
if [ -f checkForfile.md ]; then echo yes; else echo no;fi
if [ -f NocheckForfile.md ]; then echo yes; else echo no;fi
echo WITH ! -f
if [ ! -f checkForfile.md ]; then echo no; else echo yes;fi
if [ ! -f NocheckForfile.md ]; then echo no; else echo yes;fi
```
# The output
```
$ ./checkforfile.sh
WITH -a
yes
no
WITH ! -a
no
no
WITH -e
yes
no
WITH ! -e
yes
no
WITH -f
yes
no
WITH ! -f
yes
no
```
# Expected output
The expected output for all tests would be:
```
yes
no
```
However, the `-a` option does not work if used in conjunction with not ('!')1 parent 4f0a496 commit 00afc99
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
0 commit comments