From 208e310e9409d0d54ae5e19cb52f8d0f3c7f4771 Mon Sep 17 00:00:00 2001 From: Renee Margaret McConahy Date: Mon, 23 Aug 2021 01:28:21 -0400 Subject: [PATCH] bash: allow unsetting shell options --- modules/programs/bash.nix | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 5140e1aad..a896209b3 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -75,7 +75,14 @@ in # Warn if closing shell with running jobs. "checkjobs" ]; - description = "Shell options to set."; + example = [ + "extglob" + "-cdspell" + ]; + description = '' + Shell options to set. Prefix an option with + - to unset. + ''; }; sessionVariables = mkOption { @@ -146,8 +153,10 @@ in mapAttrsToList (k: v: "alias ${k}=${escapeShellArg v}") cfg.shellAliases ); - shoptsStr = concatStringsSep "\n" ( - map (v: "shopt -s ${v}") cfg.shellOptions + shoptsStr = let + switch = v: if hasPrefix "-" v then "-u" else "-s"; + in concatStringsSep "\n" ( + map (v: "shopt ${switch v} ${removePrefix "-" v}") cfg.shellOptions ); sessionVarsStr = config.lib.shell.exportAll cfg.sessionVariables;