mirror of
git://git.savannah.gnu.org/config.git
synced 2025-05-26 09:06:38 +12:00
config.sub: work around command assignment bug in some shells
When combining variable assignments with a shell command, some older shells (notably heirloom-sh and presumably also Solaris 10 /bin/sh) have a bug which causes the assignment to alter the current execution environment whenever the command is a shell built-in. For example: % dash -c 'x=good; x=bad echo >/dev/null; echo $x' good % jsh -c 'x=good; x=bad echo >/dev/null; echo $x' bad The config.sub script contains a few commands of the form: IFS=- read ... which triggers this bug, causing the IFS assignment to persist for the remainder of the script. This can cause misbehaviour in certain cases, for example: % jsh config.sub i386-linux-gnu config.sub: test: unknown operator gnu % jsh config.sub i386-gnu/linux sed: can't read s|gnu/linux|gnu|: No such file or directory Invalid configuration `i386-gnu/linux': OS `' not recognized * config.sub: Save and restore IFS explicitly to avoid shell bugs. * doc/config.sub.1: Regenerate. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
This commit is contained in:
parent
2707e389a5
commit
191bcb948f
8
config.sub
vendored
8
config.sub
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
# shellcheck disable=SC2006,SC2268 # see below for rationale
|
||||
|
||||
timestamp='2021-08-04'
|
||||
timestamp='2021-08-14'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@ -121,9 +121,11 @@ esac
|
||||
|
||||
# Split fields of configuration type
|
||||
# shellcheck disable=SC2162
|
||||
saved_IFS=$IFS
|
||||
IFS="-" read field1 field2 field3 field4 <<EOF
|
||||
$1
|
||||
EOF
|
||||
IFS=$saved_IFS
|
||||
|
||||
# Separate into logical components for further validation
|
||||
case $1 in
|
||||
@ -935,9 +937,11 @@ case $basic_machine in
|
||||
|
||||
*-*)
|
||||
# shellcheck disable=SC2162
|
||||
saved_IFS=$IFS
|
||||
IFS="-" read cpu vendor <<EOF
|
||||
$basic_machine
|
||||
EOF
|
||||
IFS=$saved_IFS
|
||||
;;
|
||||
# We use `pc' rather than `unknown'
|
||||
# because (1) that's what they normally are, and
|
||||
@ -1317,9 +1321,11 @@ case $basic_os in
|
||||
;;
|
||||
*-*)
|
||||
# shellcheck disable=SC2162
|
||||
saved_IFS=$IFS
|
||||
IFS="-" read kernel os <<EOF
|
||||
$basic_os
|
||||
EOF
|
||||
IFS=$saved_IFS
|
||||
;;
|
||||
# Default OS when just kernel was specified
|
||||
nto*)
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.16.
|
||||
.TH CONFIG.SUB "1" "August 2021" "GNU config.sub (2021-08-04)" "User Commands"
|
||||
.TH CONFIG.SUB "1" "August 2021" "GNU config.sub (2021-08-14)" "User Commands"
|
||||
.SH NAME
|
||||
config.sub \- validate and canonicalize a configuration triplet
|
||||
.SH SYNOPSIS
|
||||
|
Loading…
x
Reference in New Issue
Block a user