Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Peng Yu Newsgroups: gnu.bash.bug Subject: performance bug of [[ $x ]] Date: Sat, 7 Mar 2020 16:48:46 -0600 Lines: 25 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 1583621333 2066 209.51.188.17 (7 Mar 2020 22:48:53 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=OylCkNFsyR7Z4HkDZQZIZYXlFxrKZODZ4tcTJ4vtuPU=; b=R33u/YGoJ85Fom3BHyoRv2dfICX8ps3QcOoCNA2lQulLS8YUECKNBarRA1x3bWv4cs vKgbe9vdfCkd4rwRURkIwfeCYdMBusM7Er3sZDR8DKlqeyOgUJjgUpNErcBkoD1KoKhB FSmj+jpxWM3OkQTk7yhjK3Rz0+OgJnjd5XX8vL95aDpIFUXVpfSGz9nQbN/2pnK9KRFb 47+1hxFGMM427OffymzvICyzb/Pj2O7mcmuI16Ke1sKKewK44xYPb+obU9DqQTLCEJN7 tqhdhEWIQ/rOCl8pB8o6bRiEQgNjBNGLLDWiP2u4a+1Fswdk+k8fQ7eA7ZVW42QR3JnW u3bQ== 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=OylCkNFsyR7Z4HkDZQZIZYXlFxrKZODZ4tcTJ4vtuPU=; b=if0WHqB9p8L48DVqQydtsQd9rA8EtRgRmCpnMez8wPwsGt8IKOeAYgtGQPOoa9LQFl Ozv6AOlR9ilx8iuOdT6HDUK+pYUtLkTIkWiQRq+e02ieUGOeDX9zav6jEVbpMxO3tp9o xIq7STUlUhocNhnlPU8lU9K9S0/24+9AEq3mLVAECuFecKOymWOiQjlz1AZRPfGcHC/a HJey0Rh43QcOYLA7xhK2GlZ/NlDzRoVJkzbju/QJgwMIAM4uCQhQ/vyoPDOqV8/JtxGq UiLgMaF1hWBM70rEGWowgZdL3fBAOUzmLT/rQ0O4Yu5E/vJtS8OFhvNqHdD1PrFl4+2H +tmA== X-Gm-Message-State: ANhLgQ2/mHkAElSbsShQeWsXECNaM4CrjHGV0Fs+kf/oe1sY8P844OlB NOJejKGnEKV9VISSJLG+ymS485kaogvOyii0MYokhA== X-Google-Smtp-Source: ADFU+vuJmt5gLdMURChndcC0kVsbehJdkfQajfdsiTR6BGP0w6T5/bVUcJtEIur/TZ/bXa4izo2X9l88pNiGjMRR6R4= X-Received: by 2002:a92:c848:: with SMTP id b8mr9040860ilq.153.1583621327760; Sat, 07 Mar 2020 14:48:47 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::130 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:15998 [[ $x ]] just tests whether the variable $x is of length 0 or not. So its performance should not depend on how long the variable is. But the following test case shows that the run time does depend on the length of the variable. Should it be considered as a performance bug of bash? $ x=$(printf '%.sx' {1..1000000}) $ time [[ $x ]] real 0m0.004s user 0m0.003s sys 0m0.000s $ x=$(printf '%.sx' {1..10000000}) $ time [[ $x ]] real 0m0.043s user 0m0.039s sys 0m0.004s -- Regards, Peng