Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Grisha Levit Newsgroups: gnu.bash.bug Subject: test -v and environment variable names with subscripts Date: Tue, 17 Jul 2018 17:19:20 -0400 Lines: 18 Approved: bug-bash@gnu.org Message-ID: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1531862378 19720 208.118.235.17 (17 Jul 2018 21:19:38 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=8AIYcagR5jIekEfzkMpM4k1kmx4H2wM1L115lhSQ5Q8=; b=rqWCuDgnJjIZoICdGCNVOPqMgyo++dlekk9NAilf4sV1OjjWdZaYHNYH5ITs9kMiz9 BNtF/zoxvD3aWYbkKbVX4lUxNLHkNHuaT8wfo8l907Hyua8PX9fuPKs3voNTEEctfCcm hyO+QbsybUhyxXOAZEKIw8GMuJULrOcBYaQCXeYrJ++7cxBkrNAIjXNkhyO/10gP0ZDp 611oNgxcON2blWXqPbXXE05WkroLS/Bz2DjdUk2o+UpPXtTNFOt9ypXZCVChmN3jXh8V l4eqFrhlxFX4IJHFwSemRz2FysW2EUAyE5PhjGBwI4hHRwSr9k4BfReYg8QhJaOxIU6d GeIA== 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=8AIYcagR5jIekEfzkMpM4k1kmx4H2wM1L115lhSQ5Q8=; b=RWsyQhZ2O1haEXhxwqC14fCsFXfDqZW6JwLoBQ6qhf5pzEZPgEB2WYxA9nDWYKgtjB PH2eKk7XR/1SrbVepXnKHKNluhuDzMoUwTKQeFE/eUf+9xwOI0qOjgh/5ymn/qZf1fIZ VnLJXkT8UX6k6jSBEpaifo2QK4cvC8cSHyFJXCNDpBRtdlwm4ax0JuD0NMOT0yZOBWAP QCppaTdZWGmPv8xL9WRXTKoM6pGFdonJDrLjYggTBxcCnjYy+OYMnkvhFXpwr7oc8U8z Af8W+cvhJCufywGYbQqurxVd6M0FMJdshj5F1ITDgCiNq7p2H+SkMVe0HZuTCVktqH0H zgxw== X-Gm-Message-State: AOUpUlFYqFHqAqh3F5ku2c15B7b8Xcb+BqSJ5nU4HoFDxsP4skXVFhum WwsRx1sN8biNnHhI13XS58mG2A3hkPwK8XWlEf7LY5M9 X-Google-Smtp-Source: AAOMgpevLE3XigEQja7/0tp1mYsFNSmkrv1zCzewQGkS1OajV4j+NdK+ZKkAGm/R9fhsnC+Fef3Nm08X6tseGHJH8b4= X-Received: by 2002:a2e:2d2:: with SMTP id y79-v6mr2473519lje.100.1531862371834; Tue, 17 Jul 2018 14:19:31 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::22a X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14355 When there is a variable with a name that includes a subscript in the environment, test -v looks at that variable rather than an array with that subscript. I just posted about two ways [1] [2] to create variables like `var[0]=X' and if both of those methods are fixed than this report might be moot -- or it might still be worthwhile to guard against this if other bugs similar to the above-referenced ones exist. For example: $ set -u; unset var; f() { test -v 'var[0]'; echo $?; }; var[0]=X f 0 -bash: var[0]: unbound variable [1] https://lists.gnu.org/archive/html/bug-bash/2018-07/msg00068.html [2] https://lists.gnu.org/archive/html/bug-bash/2018-07/msg00069.html