From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16027 invoked from network); 3 Aug 2021 20:40:25 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 3 Aug 2021 20:40:25 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1628023225; b=a5fXlkPS3Pm/DE1BrAqgNhl/e+2CJQU8c6ucEfJrVmX6D708SwxOXCkBbwWnrmfgK4CpyoN885 r7wyBb/f6p4yCemMWkpcAypy667+s9sqf+ryL/KvC54+wuCOJaRr1qZOdQe0cevWjRXbmQ3Kp4 KDkuqQ83iXsKZBjuHVDZhaCjvOMtkq181Ylj4+C1MtCoWbUcQ/SxnqQsEadKPcsrHVOgG9xT0B NTYv8/VEoBSfnAofmZa5YN2ept2gMV8DlG4Oi46kZTxCYzWqGb9Rv9O8d39zVuKgOaybdlB9tj wlRW+gMckOrl/GFNgUDlmfqaIxFfJp1fva3u45YJRS2zjQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f173.google.com) smtp.remote-ip=209.85.219.173; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1628023225; bh=FnruiziqNh4P3i4DchrG3HXQ7OVEnGqJs95AVk4IXjI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=IKoF2TPMDGC1zw1w03EyzE9tZ9/qBSc8CR56poejwbxbStlhM3Bx1og3McqTqucrF4Xz2awbRP Tv9BJehbraILNT54qSTYegwR0Sggz/LY4zIgSAgW87hX8a7ZoJnpnnS1o66YHrPWNhV4ob2ttB f6JYs8UrQHFNAwzMGYYLqhw1AtTedhh9IXDEiNqoVeH88Beoh4/l2gPCI92hPPSxW7Ay83jp5P wD77JyHZgcq0iYJWXe9UuuzvT4VltjhZ7RWTqO3McaOQ5z1DNmLWza8NxmqMem2LhlEiSxrSPt sohHJh3gQumYedqKJks7uQ73EUIwdTF3pi4jBzgU0E7u1Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=3LjyM6tgh9EytoBrgQUCKeCRCxL/LA/f7XET9Eiih7c=; b=AohBGqNm/H3/arvKKPx9DyCx/I snETzRUNchafiE7UXwBFFSUZxj2S7AWBNh8lG5PStQg1KtIiGA324824hukbHnOHNGK6Dy9Ngp2XZ ZqN5BYbf5xl19w2OPhotjPq1U+Tn9mduENfLeYYRLKrpvlLHxCFX60VhImdBqCzELRVSk+usic/Uk FzSiXax8sBoeXG8fFBCIupLmyDJxyznbdyGKyQ0IDnigxoaQjmHA1eqoU4aaKdf7GRV/FFsrCWM0Y OfkdyrdmC+tVEoj83owVw/3gEm/K38eLr7yioluXWb2CM1O+uxt+MfWfA2Qfc9LxvfZTGVwu7u+39 hdM/F0Rw==; Received: from authenticated user by zero.zsh.org with local id 1mB1D5-000Jct-3U; Tue, 03 Aug 2021 20:40:23 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f173.google.com) smtp.remote-ip=209.85.219.173; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-yb1-f173.google.com ([209.85.219.173]:39787) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mB1CO-000Ivm-Pb; Tue, 03 Aug 2021 20:39:41 +0000 Received: by mail-yb1-f173.google.com with SMTP id p145so718875ybg.6 for ; Tue, 03 Aug 2021 13:39:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3LjyM6tgh9EytoBrgQUCKeCRCxL/LA/f7XET9Eiih7c=; b=JNGFxhExfh2kryiW0PjPG9k5h5y+ldT3zgbZRAodBkz6Pz/JGFSfia/szbH8DpQQLu pqPUgO4icecP35BTBwJpuzYblmE3xQHqYbCEN567SKlD+JKuy8pOW7DGtDeHFLSHLIbH 9anTxXJatozhGeKxtxkKXJvDnI5VfswQ98uzB3LKfwzCFF6jx9P+IBxs1mRshsbVHl2a 3Rm6YUDuDISWfMR6z4v9ZBXUAk3YNwx0ul3qElFr3TmzPDtvNPx7CGsFlF+R8UGoK0oB 8E62xLA5/kpGzYHBxdILW+zyqU9a2/EOC+4x0wg3fFtDiRUq1wkSQ29ObdTtLANfEkAQ 8QxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3LjyM6tgh9EytoBrgQUCKeCRCxL/LA/f7XET9Eiih7c=; b=COLwMk/uYcldqb3BllRG3HbrlXbTDB+YtJirmIWkZMej8Z2ZHYfV/xrtunYIJ5JTIh 2shSbSzdXIbEA1CDCHyMZ2t0Ju+nz+IjcptTRNKMNrn1T7Kf6o0qLhRNpgjuPcDjBDBW 2dFruwo2XFer92Plp+DeH85D92O1h1nk89lu/cZYMzMcIdzContA7pXSTPh2yw2j5fFd KM7wIVyqS16b7+XH4mNAe8eUIeG4EpP6ij09Zr40bws5lnYG2yY0GqWILnD1VrIm1jUe VanaTZu3eC9NX+fr+2Hjod9qz+4BZlkSMAshkoOXVIpWm5P6kKxFl4LSBTRhGHX9k/h7 TH6w== X-Gm-Message-State: AOAM531YKsus6xnkgu2h5lA5pxGvSm1s6VCmnfEmJv/eXbCWibwlkmAI lPLt+RrES7gW4efPBVA8+JpdgnDVKw93GFgJkFl/ug== X-Google-Smtp-Source: ABdhPJzn3VYskAheOTE90up8sbI0MH36Vbj14H3cRrLmkEbG3BcHMhKBSZcv1CHANvUX0/zx63tPYJEjv54Nt+9AJus= X-Received: by 2002:a25:e042:: with SMTP id x63mr31918808ybg.398.1628023179653; Tue, 03 Aug 2021 13:39:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Tue, 3 Aug 2021 13:39:28 -0700 Message-ID: Subject: Re: limit scope of variable To: Ray Andrews Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 26845 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Tue, Aug 3, 2021 at 1:15 PM Ray Andrews wrote: > > I have a function that requires this: > > local IFS=$'\n' > > ... but the function calls other functions in which I need to protect > $IFS from that change. Can I limit the scope? That's what the zsh/param/private module is for, but unfortunately, because IFS is a special parameter, you can't declare it private. You can, however, declare IFS local in both functions, to avoid having to explicitly restore it in the "inner" function. calling_function() { local OLDIFS=$IFS local IFS=$'\n' called_function } called_function() { local IFS=$OLDIFS ... } However, it seems odd to me that called_function cares about the $OLDIFS value. I would think it either does not care, or needs to declare its own value explicitly. That is, I would think you don't need $OLDIFS, and instead can do something like called_function() { local IFS; unset IFS # use default ... }