aws / aws-cli

Universal Command Line Interface for Amazon Web Services
Other
15.6k stars 4.14k forks source link

Allow to specify shell for bash scripting #7920

Open dantonyuk opened 1 year ago

dantonyuk commented 1 year ago

Describe the feature

Currently bash scripting aliases use /bin/sh to execute the code. Unfortunately, on different systems it's different shells. E.g. it's bash v3 on Macos, and dash on Ubuntu/PopOs. It hinders creating portable aliases.

Use Case

I share my dotfiles among the devices I use, and it's really hard to write scripts that could be executed on all the systems. E.g. dash does not support arrays so I have to write cumbersome code to emulate it. With the ability to specify the shell I'd write the scripts only for this particular shell.

Proposed Solution

Allow to specify shell for aliases and pass it as shell parameter here: https://github.com/aws/aws-cli/blob/85d72cd19e556ac41f3f7a4fe2eb5527a4bbb029/awscli/alias.py#L283

Other Information

No response

Acknowledgements

CLI version used

2.11.12

Environment details (OS name and version, etc.)

*

tim-finnigan commented 1 year ago

Thanks @dantonyuk for the feature request. I found a related one here requesting PowerShell support for aliases: https://github.com/aws/aws-cli/issues/4285. We may want to consolidate these issues for tracking going forward. More investigation is needed into how the team might approach implementing these feature requests.

vergenzt commented 2 months ago

This would have been helpful for making my workaround at https://github.com/aws/amazon-ssm-agent/issues/358#issuecomment-2344204160. However I worked around this limitation by just invoking bash from within the alias (to use its ${*@Q} parameter re-quoting feature). 🙂