bitwalker / bitwalker/distillery
Support custom command script files with extensions other than `.sh`?
- Dominant language
- Elixir
- Stars
- 3k
- Forks
- 398
- PR merge metrics
- No merged PRs in 30d
Description
### Steps to reproduce
In my project's `rel/config.exs` file, I just added two new ('something') custom commands:
```elixir
release :my_project do
set version: current_version(:my_project)
set commands: [
disable_something: "rel/commands/disable_something.bash",
enable_something: "rel/commands/enable_something.bash",
seed: "rel/commands/seed.sh"
]
...
```
But after deploying a release I don't see the new commands – but I DO still see the `seed` command:
```
$ bin/my_project
USAGE
my_project [options] [args..]
COMMANDS
start Start my_project as a daemon
start_boot Start my_project as a daemon, but supply a custom .boot file
foreground Start my_project in the foreground
...
seed (custom command)
```
And when I try to run one of the new 'something' commands:
```
ubuntu@ip-172-31-64-81:~$ web/partially/bin/partially enable_maintenance_mode
'enable_maintenance_mode' is not a valid command
...
```
[This code in `priv/libexec/commands/help.sh`](https://github.com/bitwalker/distillery/blob/6700edb017804e51aec14dedb8df888d1db4e63c/priv/libexec/commands/help.sh#L38) (and similar code elsewhere that I am imagining exists) seems like it might be why the new commands aren't listed:
```elixir
for command in "$REL_DIR"/commands/*.sh; do
[ -f "$command" ] || continue
__has_commands=1
echo " $(basename ${command%.*}) (custom command)"
done
```
I believe I saw elsewhere that Distillery explicitly requires Bash and not any Bourne-compatible shell. I picked-up the habit of naming my own *Bash* shell scripts with a `.bash` extension from [my favorite Bash guide author](http://mywiki.wooledge.org/BashGuide/CommandsAndArguments#Scripts):
> Also, please refrain from giving scripts a `.sh` extension. It serves no purpose, and it's completely misleading (since it's going to be a `bash` script, not an `sh` script).
[Based on the above, I figured `.bash` was clearer than no extension, and more accurate/precise than `.sh`.]
[The current docs](https://hexdocs.pm/distillery/extensibility/custom_commands.html) include examples of shell scripts for custom commands with *no* extension in the script file names too – those don't seem like they would work either.
But this is a very minor issue, easily worked-around, and I think, for my own project, just calling the relevant code via the builtin `eval` or `rpc` commands is just as good (and a little better in not requiring any extra config or an extra shell script).
### Verbose Logs
[Please let me know if these would be useful.]
### Description of issue
#### What are the expected results?
All of the custom commands should be listed, maybe regardless of the extension (if any) of the corresponding shell scripts.
#### What version of Distillery?
`2.1.1`
#### What OS, Erlang/Elixir versions are you seeing this issue on?
```
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS"
```
Elixir is version `1.12.3` and Erlang/OTP is `24.0.6`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with priv/libexec/commands/help.sh and the release command-handling code that discovers scripts under the release's commands directory. Compare how files ending in .sh are found with the documented extensionless examples and the .bash files in rel/config.exs. Done means supported custom command scripts are consistently discovered, listed, and runnable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, elixir
- Domain
- cli, release
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100