From 2501cf38e8fc548e2269f696f70bd19a37d8c97b Mon Sep 17 00:00:00 2001 From: Joe Ferguson Date: Fri, 11 Oct 2019 13:30:56 -0700 Subject: [PATCH] Improve _is_sourced check from https://github.com/docker-library/postgres/pull/496/commits/d1cc08935c360ea576943708d8766b33c9b1e1f9 --- .template.Debian/docker-entrypoint.sh | 4 +++- 5.6/docker-entrypoint.sh | 4 +++- 5.7/docker-entrypoint.sh | 4 +++- 8.0/docker-entrypoint.sh | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.template.Debian/docker-entrypoint.sh b/.template.Debian/docker-entrypoint.sh index a2d146b85..dc6f50ab1 100755 --- a/.template.Debian/docker-entrypoint.sh +++ b/.template.Debian/docker-entrypoint.sh @@ -42,7 +42,9 @@ file_env() { # check to see if this file is being run or sourced from another script _is_sourced() { # https://unix.stackexchange.com/a/215279 - [ "${FUNCNAME[${#FUNCNAME[@]} - 1]}" == 'source' ] + [ "${#FUNCNAME[@]}" -ge 2 ] \ + && [ "${FUNCNAME[0]}" = '_is_sourced' ] \ + && [ "${FUNCNAME[1]}" = 'source' ] } # usage: docker_process_init_files [file [file [...]]] diff --git a/5.6/docker-entrypoint.sh b/5.6/docker-entrypoint.sh index a2d146b85..dc6f50ab1 100755 --- a/5.6/docker-entrypoint.sh +++ b/5.6/docker-entrypoint.sh @@ -42,7 +42,9 @@ file_env() { # check to see if this file is being run or sourced from another script _is_sourced() { # https://unix.stackexchange.com/a/215279 - [ "${FUNCNAME[${#FUNCNAME[@]} - 1]}" == 'source' ] + [ "${#FUNCNAME[@]}" -ge 2 ] \ + && [ "${FUNCNAME[0]}" = '_is_sourced' ] \ + && [ "${FUNCNAME[1]}" = 'source' ] } # usage: docker_process_init_files [file [file [...]]] diff --git a/5.7/docker-entrypoint.sh b/5.7/docker-entrypoint.sh index a2d146b85..dc6f50ab1 100755 --- a/5.7/docker-entrypoint.sh +++ b/5.7/docker-entrypoint.sh @@ -42,7 +42,9 @@ file_env() { # check to see if this file is being run or sourced from another script _is_sourced() { # https://unix.stackexchange.com/a/215279 - [ "${FUNCNAME[${#FUNCNAME[@]} - 1]}" == 'source' ] + [ "${#FUNCNAME[@]}" -ge 2 ] \ + && [ "${FUNCNAME[0]}" = '_is_sourced' ] \ + && [ "${FUNCNAME[1]}" = 'source' ] } # usage: docker_process_init_files [file [file [...]]] diff --git a/8.0/docker-entrypoint.sh b/8.0/docker-entrypoint.sh index a2d146b85..dc6f50ab1 100755 --- a/8.0/docker-entrypoint.sh +++ b/8.0/docker-entrypoint.sh @@ -42,7 +42,9 @@ file_env() { # check to see if this file is being run or sourced from another script _is_sourced() { # https://unix.stackexchange.com/a/215279 - [ "${FUNCNAME[${#FUNCNAME[@]} - 1]}" == 'source' ] + [ "${#FUNCNAME[@]}" -ge 2 ] \ + && [ "${FUNCNAME[0]}" = '_is_sourced' ] \ + && [ "${FUNCNAME[1]}" = 'source' ] } # usage: docker_process_init_files [file [file [...]]]