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 2593 invoked from network); 3 Feb 2021 02:22:37 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 3 Feb 2021 02:22:37 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1612318957; b=pLTllIjbIf1vYRJFehqhmfCCbOke8a7HWi4PyR+DLr8WbMaeZB2hqILaXKufT7T/yeR1nBEArM Nx85I1p3k/pj2V2E2ZHIE53sPwTUSX8C0dn3mERo3A6FL21sGHRL6L/RlAPvzrKE4nwtxzXQdi 9+LMNpEfsj7JxBkjL+yXaXtOFbFgwe+slUHoA8w+eRjBuaD5hZgnbqEqqVWq6K7nEkBSm2dJul +jkeKSJ2zWGS1fGGTaKXOeG7LqWY2hulXM2UYQpC9i+X05xuPo4DVbnb0oS82wSd1z5PiTTYeA VL3mESYWyABWTbF1XLEkWUXKDiha1C7Ub2huzEWo1PhqdA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f174.google.com) smtp.remote-ip=209.85.167.174; 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=1612318957; bh=1qQwypK3LbyM7IIJxz4MKjutfOyrFtcdOr+yeK4asfE=; 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=lhPjtYmjIXw19QAtc0OPjukp9B+90eA9gRz8JjVATETp+Qi/VMrFAQtNqRNA/izDb+oanlzK6n j5NzYRswOnfn1AqgE41hGsT9mUryHY94KMPQnJQ5VTlekxL5A/DLohgCV2OQ/pHfwROUjXW1x7 VYeW7fnCpf096/15d0pFjE+aBSaCgkyIDaNt8D41pgcC/fPp6UYJ6JurRPf88zwKy2m+HcuOcy 2J1+QEr+DkWP1eo9RJ/qJ2jifoG6FBygf8CAyd75UOT5mUTdKGa6pgsxgdAqJf6gaFRBsvtbAV uAPQAxlxWXYneQKEqYNQD+5hV6JfLNyLPQTUFS6yqHGx9w==; 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=EnrKly6P2CHnVuzgytxI2D8TrBeJZ8xkgIQ0Z7r8mjA=; b=mJ0aLLC9IdtK4mvhTVQIF4+FS8 L1Wa67Ny6jHp6iSuIHraXTUCyYrFT8iljkMqbbQJfK3sPWGQl2/9XUlmANVqA4A2dHEoqSGEgo3iU GwDRYrj+eDhlqeN7QmdZh7CDdYh9uF8flqr1m2A0dNTxvO9NUYSuzov2XnVMDqlNNoYJjZg0vnc4F 05PIEJ2fVDQRo5Y3mn3twXqJ4xl1bw0cVQk5Kgp4vhfr2j4WsvC5ct7cYAkfGSEwZ03qqWPZcfjEy +qgQ1Tcyc7rXydZiGwElmhARda3H1wbS6NzdraWWkytEayi06BLIYlyjrcjGpwxf3Xn+AfwYlnIfX +eU24ZcQ==; Received: from authenticated user by zero.zsh.org with local id 1l77oP-0003q2-1x; Wed, 03 Feb 2021 02:22:33 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f174.google.com) smtp.remote-ip=209.85.167.174; 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-oi1-f174.google.com ([209.85.167.174]:33141) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1l77nr-0003Rz-1N; Wed, 03 Feb 2021 02:21:59 +0000 Received: by mail-oi1-f174.google.com with SMTP id j25so25204128oii.0 for ; Tue, 02 Feb 2021 18:21:58 -0800 (PST) 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=EnrKly6P2CHnVuzgytxI2D8TrBeJZ8xkgIQ0Z7r8mjA=; b=u8zYhV0ZZ7ZZnvYdPREQKt58gM4JNG9TLMPbyejtJ/c6Hvwl8PZ9OiGMcHff5xSrF8 3E7Snkuye9mdbkcZ+xgN7dt6bsDVCD/fpStuUS1FdkqLMlT14s0N+oHY1F3+tgQW/5MN I6hH/QmiBq2zYsBN9uAAtCgGcE10kFBC/LWOWLhDhyYtmZHbRr5Vpb01F0Awgsq947jT 2bnbyF0vGFY+PWtqdHU5MOr/h9/VPr1oJD/tHg+YVDu3pyi7ZnBePW1WjQmXGCo6sItt QzaSbU3XN5v4Ip++yW+YMGRXITe581CPnXos8nZWUKMnY46+ibSqJl5/hVnXr85bGmwU MlGg== 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=EnrKly6P2CHnVuzgytxI2D8TrBeJZ8xkgIQ0Z7r8mjA=; b=ROyace3EIBzWq1zPBJnnkN0qoEMtPh0dJlR+0F8iQsnJ4j3wGHNV7CyKIIO8oLSDmm U7u/oSL/fmnmEw63xBw6vsLnXpJjPy+KyYXGWaJdy8belZ0Z/dWl1DqvP9y9WJJd+Ykw /Vym7KeNr7iwF1aR4OAfObwkeIHcq+0UunahOeZ+18To5QA/eZn3shR/EpBie3pAtjlz e6vrQa7XwnDT52OxG1+siXxkVjBeOUc6oCuO78bfJ0qlLwyV5Cdzb4kwJ8AhJOVitBL0 Pxw1oNzlTeRufhNcv6lAPhbVWG0yeLTP8lpx3CVHx4qavJMOViSTq4reR/bXRqELuPlu vrSQ== X-Gm-Message-State: AOAM530mRBq+c/dcSHG/iL6UU+krpH4aApjbb6xPtHzos9I6o3zZ043m VePrtZ5l1UIzuxFxuVc+YDwwLRwknl7SEeyRDBxbiw== X-Google-Smtp-Source: ABdhPJwsaJM5OoidgdalSpq68L86RctTxuVusBbA4/PrvIa2LWEj8eNRrNgKmkAg/4coAyb7WJAaH7z6hQ5pf72dwZA= X-Received: by 2002:aca:808:: with SMTP id 8mr566757oii.84.1612318917698; Tue, 02 Feb 2021 18:21:57 -0800 (PST) MIME-Version: 1.0 References: <52dba8e4-2538-7c96-ecd5-66e017ab2b8e@eastlink.ca> <36596ab3-14b6-da57-e40b-3e66d9ffbb5a@eastlink.ca> In-Reply-To: <36596ab3-14b6-da57-e40b-3e66d9ffbb5a@eastlink.ca> From: Bart Schaefer Date: Tue, 2 Feb 2021 18:21:46 -0800 Message-ID: Subject: Re: array with newlines preserved as literal text To: Ray Andrews Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 26454 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: Archived-At: On Tue, Feb 2, 2021 at 3:31 PM Ray Andrews wrote: > > Complicated. It goes back to my first bitch with zsh, namely not being > able to capture the literal invocation of a function (along with it's > tail) unexpanded, just as you'd see in history. I'm not entirely sure I understand what that means, but maybe it's this? _fn2hist() { emulate -L zsh local cmd=$1 shift if [[ -n $functions[$cmd] ]] then print -rS "${$(functions -x 2 $cmd)#$cmd} ${${(qq)@}}" fi $cmd "$@" } Intended to be used like this: myfn() { : do whatever myfn does } alias myfn='_fn2hist myfn' What this does is turn the body of "myfn" into an anonymous function, and stuff that into the history followed by the original arguments, and then run the function. At this point if you up-history, you'll get something like ubuntu% () { : do whatever myfn does } 'original' 'arguments' That could be a very long history entry, if "myfn" is complicated ... but if you hit "enter", it should behave just like "myfn" did. With one caveat: If the function depends on getting its own name from $0 or some similar trick involving $funcstack, etc., that will fail.