Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'. replace.sh' fails for POSIX shells (e.g. Bash as 'sh') #1071

Closed
Apteryks opened this issue Mar 7, 2024 · 0 comments · Fixed by #1076
Closed

'. replace.sh' fails for POSIX shells (e.g. Bash as 'sh') #1071

Apteryks opened this issue Mar 7, 2024 · 0 comments · Fixed by #1076

Comments

@Apteryks
Copy link

Apteryks commented Mar 7, 2024

Hi,

I had the following problem attempting to build this project, setting the shell used for the build to Bash (5.x) provided sh, which behaves in a POSIX compatible fashion (see "info (bash) Bash Startup Files").

The error was:

# create a clean nx-X11/.build-exports space
rm -Rf nx-X11/.build-exports
mkdir -p nx-X11/.build-exports/include
mkdir -p nx-X11/.build-exports/lib
# copy headers (for libnx-x11-dev)
cp -aL nx-X11/exports/include/* nx-X11/.build-exports/include
# copy libs (for libnx-x11), we want the targets of the links
echo "PWD: $(pwd)"
PWD: /tmp/nx-libs-3.5.99.27
. replace.sh; set -x; find nx-X11/exports/lib/ -name "libNX*.so" | while read libpath; do \
    libfile=$(basename $libpath); \
    libdir=$(dirname $libpath); \
    link=$(readlink $libpath); \
\   
    mkdir -p "$(string_rep "$libdir" exports .build-exports)"; \
    cp -a "$(string_rep "$libpath" "$libfile" "$link")" "$(string_rep "$libdir" exports .build-exports)"; \
done;
/gnu/store/rib9g2ig1xf3kclyl076w28parmncg4k-bash-minimal-5.1.16/bin/sh: line 1: .: replace.sh: file not found
make: *** [Makefile:258: install-full] Error 1

This happens because replace.sh is looked up from PATH, where it's not found. Since we aren't using /bin/bash, the POSIX behaviors is to only look from PATH for relative file names. The solution is to use the absolute file name of the replace.sh shell "library", like so:

. ./replace.sh

Thanks to emanuele6 from #bash on libera.chat for the kind explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant