aws / aws/aws-cli

install script multiple issues

Open
#7,310 6 comments 0 reactions 1 assignee Claimed by @RyanFitzSimmonsAK View on GitHub
bug installation p2
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### Describe the bug

Hi

I noticed multiple tiny issues in the install script, while looking into the first one in the list below:

1. The `-i` and `-b` options do not check if the directory name has been supplied. The `shift` command fails, but the script continues.
2. `shellcheck` complains about a self assigned variable: `INSTALL_DIR="$INSTALL_DIR"`
3. `create_bin_symlinks()` does not catch the `mkdir` error
4. The install dir should be verified that it is absolute pathname, otherwise `create_bin_symlinks()` and `create_current_symlinks()` will generate bad symlinks.

### Expected Behavior

1. The script should exit if argument is missing
2. The assignment is superfluous, does not affect the behaviour
3. The script should exit, if `mkdir` fails
4. The binary symlinks should be valid

### Current Behavior

1. There is an error message, but the script continues
2. Does not affect the behaviour
3. An error is reported, but the script continues
4. If the supplied install dir (from `-i`) is a relative path, the symlink may be invalid

### Reproduction Steps

In all cases, unpack the zip file and change to that directory:

1. run install with `-i` or `-b`, but no arg

```
./install -b`
./install: line 64: shift: shift count out of range
...
```

2. run `shellcheck` against the script
```
shellcheck install

In install line 81:
INSTALL_DIR="$INSTALL_DIR"
^---------^ SC2269 (info): This variable is assigned to itself, so the assignment does nothing.

For more information:
https://www.shellcheck.net/wiki/SC2269 -- This variable is assigned to itse...
```
3. create a file that has same name as the directory being created
```
touch bbb
./install -i aaa -b bbb
mkdir: cannot create directory ‘bbb’: File exists
ln: failed to access 'bbb/aws': Not a directory
ln: failed to access 'bbb/aws_completer': Not a directory
You can now run: bbb/aws --version
```
Note: the script should have aborted after the `mkdir` error.

4. same steps as above
```
ls -l aaa/v2
total 4
drwxr-xr-x 4 fy fy 4096 Sep 29 16:54 2.7.35
lrwxrwxrwx 1 fy fy 13 Sep 29 16:54 current -> aaa/v2/2.7.35

ls -l aaa/v2/current/
ls: cannot access 'aaa/v2/current/': No such file or directory
```

### Possible Solution

1. Check for `$#` when parsing `-i` and `-b`
2. Remove the superfluous line
3. Append `|| exit 1` to the `mkdir` line
4. Check that the value supplied in `-i` is an absolute pathname

I can provide a PR for the above, if required.

### Additional Information/Context

All the above were carried out on a Linux box.

I'm not sure how the other OSes behave, or if they use the same script!

### CLI version used

aws-cli/2.7.35 Python/3.9.11 Linux/5.19.11-arch1-1 exe/x86_64.arch prompt/off

### Environment details (OS name and version, etc.)

5.19.11-arch1-1 GNU/Linux

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.