[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/buffer-env 6d70dc4db2 2/2: Pass script name as argument
From: |
ELPA Syncer |
Subject: |
[elpa] externals/buffer-env 6d70dc4db2 2/2: Pass script name as argument $1 |
Date: |
Wed, 13 Mar 2024 15:57:34 -0400 (EDT) |
branch: externals/buffer-env
commit 6d70dc4db21821b67ee2b5438f00866dbb8ac01a
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>
Pass script name as argument $1
This is a breaking change for any user who customized their
`buffer-env-command-alist'. The change is necessary because, by
convention, argument $0 is the name of the shell. This is used for
error reporting and may be used to verify that a script is being
sourced rather than executed on its own.
See for instance
https://github.com/pypa/virtualenv/blob/abe2c998bf8c7593a3a3ed2c19b3ebd55675c818/src/virtualenv/activation/bash/activate.sh#L5-L8
---
buffer-env.el | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/buffer-env.el b/buffer-env.el
index 0096f7bee1..c4f6b4eabe 100644
--- a/buffer-env.el
+++ b/buffer-env.el
@@ -67,27 +67,27 @@
(defcustom buffer-env-command-alist
`((,(rx "/.env" eos)
- . "set -a && >&2 . \"$0\" && env -0")
+ . "set -a && >&2 . \"$1\" && env -0")
(,(rx "/manifest.scm" eos)
- . "guix shell -m \"$0\" -- env -0")
+ . "guix shell -m \"$1\" -- env -0")
(,(rx "/guix.scm" eos)
- . "guix shell -D -f \"$0\" -- env -0")
+ . "guix shell -D -f \"$1\" -- env -0")
(,(rx "/flake.nix" eos)
. "nix develop -c env -0")
(,(rx "/shell.nix" eos)
- . "nix-shell \"$0\" --run \"env -0\"")
+ . "nix-shell \"$1\" --run \"env -0\"")
(,(rx "/pyproject.toml" eos)
. "\
-backend=$(sed -nr 's/^build-backend\s*=\s*\"([a-z]+).*/\\1/p' \"$0\")
+backend=$(sed -nr 's/^build-backend\s*=\s*\"([a-z]+).*/\\1/p' \"$1\")
case $backend in
poetry|pdm|hatchling) ${backend%ling} run env -0;;
*) echo >&2 \"Unsupported build backend '$backend'.\" && exit 1;;
esac")
(,(rx ".ps1" eos)
- . "powershell -c '& { param($script) . $script > $null; Get-ChildItem
env: |\
+ . "powershell -c '& { param($ignore, $script) . $script > $null;
Get-ChildItem env: |\
% {\"$($_.Name)=$($_.Value)`0\"} | Write-Host -NoNewLine } '")
(,(rx any)
- . ">&2 . \"$0\" && env -0"))
+ . ">&2 . \"$1\" && env -0"))
"Alist of commands used to produce environment variables.
For each entry, the car is a regular expression and the cdr is a
shell command. The command specifies how to execute a script and
@@ -276,6 +276,7 @@ When called interactively, ask for a FILE."
:command (list shell-file-name
shell-command-switch
(buffer-env--get-command file)
+ shell-file-name ;Argument $0
file)
:sentinel #'ignore
:buffer (current-buffer)