docker icon indicating copy to clipboard operation
docker copied to clipboard

"In POSIX sh, 'local' is undefined." ShellCheck problem in the entrypoint scripts

Open brlin-tw opened this issue 7 months ago • 4 comments

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 local command usage.
  • Change the shell interpreter to bash.
  • Suppress the warning using ShellCheck directives and call it a day.

References

brlin-tw avatar May 05 '25 01:05 brlin-tw

Drop the local command usage.

Feel like doing a PR that adjusts the local variable names?

joshtrichards avatar May 07 '25 15:05 joshtrichards

@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?

enochval avatar May 17 '25 10:05 enochval

@joshtrichards

Feel like doing a PR that adjusts the local variable 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 avatar May 17 '25 12:05 brlin-tw

@brlin-tw @joshtrichards I have raised a PR to resolve this issue, kindly review and revert. thanks.

enochval avatar May 17 '25 19:05 enochval