Repository navigation
One-liner with which behaves differently from just running in bash
#2184
Replies: 1 comment
|
Each non-shebang recipe line is executed in a fresh shell. That explains why the three which calls do not share shell state, but the alternating result specifically points to your shell initialization/environment changing PATH between those fresh invocations (for example a virtual-environment hook such as direnv/pyenv/mise, or a shell startup file that prepends/removes .venv/bin). Use one shell process for the whole recipe and resolve the executable before creating the link: There is another trap in the original: once .venv/bin/python3.10-config is first on PATH, which may resolve the destination symlink itself. Re-linking the file to that value can create a self-referential symlink. Capturing the intended external target first—or using the known absolute path—avoids that. To diagnose the alternating PATH, temporarily print printf '%s\n' "$PATH" on each original recipe line. You will likely see that the startup hook treats the new .venv state differently on each shell invocation. Just documents the execution model explicitly: each line is executed by a fresh shell, while a shebang recipe runs the whole body as one script. |
Uh oh!
There was an error while loading. Please reload this page.
I have this recipe:
Which outputs on the first run
and on the second immediate run
while running the same hydrated command in bash behaves normal - no reversing and which is always resolved to .venv folder. Why does it happen?
Am I confusing something?
All reactions