"In POSIX sh, 'local' is undefined." ShellCheck problem in the entrypoint scripts
In the run_path function and a few other places in the entrypoint.sh shell scripts, the following errors are found by the ShellCheck linter:
In 31/apache/entrypoint.sh line 24:
local hook_folder_path="/docker-entrypoint-hooks.d/$1"
^--------------------^ SC3043 (warning): In POSIX sh, 'local' is undefined.
In 31/apache/entrypoint.sh line 25:
local return_code=0
^---------------^ SC3043 (warning): In POSIX sh, 'local' is undefined.
Although the script does function correctly in this state, we probably should:
- Drop the
localcommand usage. - Change the shell interpreter to
bash. - Suppress the warning using ShellCheck directives and call it a day.
References
Drop the local command usage.
Feel like doing a PR that adjusts the local variable names?
@joshtrichards can this be assigned to me?
I will have to make the script POSIX-compliant by dropping the local, but doing this will make the variable global in the script, so I'll use unique names.
Let me know if this is okay?
@joshtrichards
Feel like doing a PR that adjusts the
localvariable names?
I would like to. Unfortunately, I don't have the time to do so at the moment.
@enochval
@joshtrichards can this be assigned to me?
Feel free to take it on.
I will have to make the script POSIX-compliant by dropping the local, but doing this will make the variable global in the script, so I'll use unique names.
IMHO, prefix all the function variables with a single underscore should do.
@brlin-tw @joshtrichards I have raised a PR to resolve this issue, kindly review and revert. thanks.