Shell scripts get wrong count of arguments
- Dominant language
- Perl
- Stars
- 3.9k
- Forks
- 213
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
Shell scripts sometimes get wrong count of arguments because of some gibberish text in one of the far ahead arguments (possibly added by keyboard?). Shell executor at times throws segmentation fault too.
This is difficult to reproduce but when it happens it continues to happens as long as the session is alive.
Steps to reproduce (all text below is faithfully copy pasted from a-shell)
1. Write a script `args_shell.sh` as following:
```
#!/bin/sh
echo "Total args: $#"
echo "\$0=[$0]"
echo "\$1=[$1]"
echo "\$2=[$2]"
echo "\$3=[$3]"
echo "\$4=[$4]"
echo "\$5=[$5]"
echo "\$6=[$6]"
echo "\$7=[$7]"
echo "\$8=[$8]"
echo "\$9=[$9]"
```
2. Execute as `sh args_test.sh`
3. This happens:
```
[my-sh-utils]$ sh args_test.sh
Total args: 4
$0=[args_test.sh]
$1=[]
$2=[]
segmentation fault
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.