amber-lang: generate bash completion; fix build on darwin (#388412)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
From cae2ad70d6202bc97623be8c7c123ee2736a4644 Mon Sep 17 00:00:00 2001
|
||||
From: aleksana <me@aleksana.moe>
|
||||
Date: Sun, 9 Mar 2025 21:19:27 +0800
|
||||
Subject: [PATCH] replace_regex: remove bash word boundary when detecting
|
||||
gnused
|
||||
|
||||
Bash linked against C libraries other than GLibc may not support GNU
|
||||
extensions of POSIX Extended Regular Regex. For example,
|
||||
|
||||
> re='\bx'; [[ 'x' =~ $re ]] && echo "1"
|
||||
|
||||
does not output the same result on Linux/GLibc and macOS.
|
||||
---
|
||||
src/std/text.ab | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/std/text.ab b/src/std/text.ab
|
||||
index fe071e33..82449a02 100644
|
||||
--- a/src/std/text.ab
|
||||
+++ b/src/std/text.ab
|
||||
@@ -19,7 +19,7 @@ pub fun replace_regex(source: Text, search: Text, replace: Text, extended: Bool
|
||||
// GNU sed versions 4.0 through 4.2 support extended regex syntax,
|
||||
// but only via the "-r" option; use that if the version information
|
||||
// contains "GNU sed".
|
||||
- $ re='\bCopyright\b.+\bFree Software Foundation\b'; [[ \$(sed --version 2>/dev/null) =~ \$re ]] $
|
||||
+ $ re='Copyright.+Free Software Foundation'; [[ \$(sed --version 2>/dev/null) =~ \$re ]] $
|
||||
let flag = status == 0 then "-r" else "-E"
|
||||
return $ echo "{source}" | sed "{flag}" -e "s/{search}/{replace}/g" $
|
||||
} else {
|
||||
@@ -4,7 +4,10 @@
|
||||
rustPlatform,
|
||||
bc,
|
||||
util-linux,
|
||||
gnused,
|
||||
makeWrapper,
|
||||
installShellFiles,
|
||||
stdenv,
|
||||
runCommand,
|
||||
amber-lang,
|
||||
nix-update-script,
|
||||
@@ -21,6 +24,11 @@ rustPlatform.buildRustPackage rec {
|
||||
hash = "sha256-N9G/2G8+vrpr1/K7XLwgW+X2oAyAaz4qvN+EbLOCU1Q=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# https://github.com/amber-lang/amber/pull/686
|
||||
./fix_gnused_detection.patch
|
||||
];
|
||||
|
||||
useFetchCargoVendor = true;
|
||||
cargoHash = "sha256-e5+L7Qgd6hyqT1Pb9X7bVtRr+xm428Z5J4hhsYNnGtU=";
|
||||
|
||||
@@ -29,7 +37,10 @@ rustPlatform.buildRustPackage rec {
|
||||
--replace-fail 'Command::new("/usr/bin/env")' 'Command::new("env")'
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
installShellFiles
|
||||
];
|
||||
|
||||
nativeCheckInputs = [
|
||||
bc
|
||||
@@ -43,9 +54,14 @@ rustPlatform.buildRustPackage rec {
|
||||
"--skip=tests::formatter::all_exist"
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram "$out/bin/amber" --prefix PATH : "${lib.makeBinPath [ bc ]}"
|
||||
'';
|
||||
postInstall =
|
||||
''
|
||||
wrapProgram "$out/bin/amber" --prefix PATH : "${lib.makeBinPath [ bc ]}"
|
||||
''
|
||||
+ lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
||||
installShellCompletion --cmd amber \
|
||||
--bash <($out/bin/amber completion)
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
updateScript = nix-update-script { };
|
||||
|
||||
Reference in New Issue
Block a user