Path: csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Grisha Levit Newsgroups: gnu.bash.bug Subject: shebang-less script execution not resetting some options Date: Mon, 30 Sep 2019 17:39:48 -0400 Lines: 53 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1569879605 7865 209.51.188.17 (30 Sep 2019 21:40:05 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ZZhtE91VWO+XUoxglIF9JUDxLNqQb7RenV9mrrk+5fk=; b=X7pnAIsapRic5Gd6kdl6n9MNe7/SwRhS2RYqygRQ8x8CswDPzZbYXh6ljPXc64JOW/ bsdvK4iLjqlJIzoefbV2ePTDfvWZyvo2RZYad+cm95kKwUAwAGTFIsSHPHPxvxTvgp2S 7ZLRyiLoZsc1PZ2sUGx/6iR2C04dnP/2m98Z1eEl0CHxG0ZzI5P/v7z+sXOkUZS86VgK u5s516BgUovWo2uezjAVEesVWwNfHaOqL6ZsvfO6fFRW9tCZNv41A+S1pCAf0dezQynX xMoDD+Xm9cpoGtTfBh7hL/uYcpkq7mwQtQjEGdOmD5/onHLyPQyV8s9RTx0yNMkm3NLp l4bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ZZhtE91VWO+XUoxglIF9JUDxLNqQb7RenV9mrrk+5fk=; b=uLJxQs0meov56Vpwej12A982MQJ2IIw+sxMiZ8VR7R4RI3iT1Bj/6Ayp5yK+GA63MI TOlXP1m5zcXP/eq+7WWMXMnGXYTG+LjfYyFOVkszONqiivBQdz/XDRj362++XixuQR9z W++nWKU7rZJlK5zUIx8+BK4JXl/FsQxKR8AYcU2Qnxsd2oWBdHYrUlNEzMi+L/lbmzGl XhMGDxLDUH7Kr5dkBb2vtK3bJ80xoyxgDs3loBYQxK8UhVJE56O4iT1UyWJm1D/Y8Ytl vph/HONJvsDiCnkcCsiyEmFWe0Hw+KXo11fdNdh4KfHxHQgbIJgGFgRSz1P+ye4O5Uuv lQVA== X-Gm-Message-State: APjAAAVt/gNmeE7qZYCmanWQDngtiGH0I3PqHp+xP0D0wfY9ifsm4yQy KLtm32ASXSKM2Ij06yooYhFTeBL4LTSMqnjFBGR5Bo0Hq+s= X-Google-Smtp-Source: APXvYqyl4vpX3XloVh306J4Lxaz2tNWSNLS04M0zCZplRn1AeQGaS/uRqqQbtckiTh3c1i8QnfZyPc971lpK7UHSwL0= X-Received: by 2002:a37:68d0:: with SMTP id d199mr2525330qkc.174.1569879599462; Mon, 30 Sep 2019 14:39:59 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::730 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: Xref: csiph.com gnu.bash.bug:15437 A few of the recently-added shopt options aren't getting reset when running a shebang-less script, this should fix it up: --- a/builtins/shopt.def +++ b/builtins/shopt.def @@ -349,11 +349,16 @@ reset_shopt_options () inherit_errexit = 0; interactive_comments = 1; lastpipe_opt = 0; + localvar_inherit = localvar_unset = 0; mail_warning = 0; glob_ignore_case = match_ignore_case = 0; print_shift_error = 0; source_uses_path = promptvars = 1; +#if defined (ARRAY_VARS) + assoc_expand_once = 0; +#endif + #if defined (JOB_CONTROL) check_jobs_at_exit = 0; #endif @@ -392,6 +397,9 @@ reset_shopt_options () #if defined (PROGRAMMABLE_COMPLETION) prog_completion_enabled = 1; +# if defined (ALIAS) + progcomp_alias = 0; +# endif #endif #if defined (DEFAULT_ECHO_TO_XPG) || defined (STRICT_POSIX) Maybe verifying this is something that can be added to the test suite? Something like: t1=$(mktemp) t2=$(mktemp) chmod +x "$t1" "$t2" echo "shopt" > "$t1" echo "#!${THIS_SH}" > "$t2" echo "shopt" >> "$t2" for o in $(compgen -A shopt); do shopt -s $o; done diff <("$t1") <("$t2") for o in $(compgen -A shopt); do shopt -u $o; done diff <("$t1") <("$t2") rm "$t1" "$t2"