mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-26 12:09:12 +00:00
fix(venv): make relocatable activation scripts support ksh (#5640)
It transpires that detecting the directory a script was sourced from is non-trivial across `bash`, `ksh` and `zsh`. The previous version was a one-liner and supported `bash` and `zsh` but not `ksh`. It is possible to keep the one-liner and add `ksh` support, but that is mutually-exclusive with `zsh`. Therefore, the only way to square this circle is to add an `if` block. A silver lining here is that although longer, the script is probably easier to follow as there is less code-golfing going on.
This commit is contained in:
parent
f266fb711c
commit
d05f2b258b
5 changed files with 26 additions and 8 deletions
|
@ -298,7 +298,7 @@ pub(crate) fn create(
|
|||
(true, "activate") => {
|
||||
// Extremely verbose, but should cover all major POSIX shells,
|
||||
// as well as platforms where `readlink` does not implement `-f`.
|
||||
r#"'"$(dirname -- "$(CDPATH= cd -- "$(dirname -- ${BASH_SOURCE[0]:-${(%):-%x}})" && echo "$PWD")")"'"#
|
||||
r#"'"$(dirname -- "$(CDPATH= cd -- "$(dirname -- "$SCRIPT_PATH")" > /dev/null && echo "$PWD")")"'"#
|
||||
}
|
||||
(true, "activate.bat") => r"%~dp0..",
|
||||
(true, "activate.fish") => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue