From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 356 invoked by alias); 19 Nov 2014 09:05:18 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19410 Received: (qmail 2075 invoked from network); 19 Nov 2014 09:05:06 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1416387564; bh=NmMi3R693+GpqCAQnAmvsjCldsnr9MjGNXI1yL512oY=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=Jln/1Vz9vi4PfFqsI8MRemGKzFF2nPJFcK/MDZgKOLoK6F8IQeIs+c/i3M2+hcg/GwJ/0ba08MDrjS+2KDAclkj36rrOg/izUsZRJj1rIVchSIR+ZZc9BJJrQmtvwMOmHlHb/38s4xksXsjhZV/ErlUJ9Ing44XsBHiFMzx2zdvx/6WfeXH/aHC3fmZ5jBwU7WjfXOqnjNqIom98zgDUNZ4Mm3qx5v4alPFTasejZN4iZNxUs2QiUMQSGqOAFf1JjXiDCWhknkdmaHdRo5xhbboWBSr4AkR3NibaEj8DnVFEryqXS3gHadfHwyDfeX+eegBlIgwIeL7JK6qfTnEEtg== DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=yahoo.co.uk; b=jtplPXjxqHS44xRMngMKtM7TcVZR5PxP3OzF3SogUjbPo0I2rlaxVSk6zEaqVhZcrA59nza8QkisEdL6AsoI2krELrBz5fs0XJ0uayv5HI/F0dU8LhNlBt2pcUwOlPUNAKeu83eMENPx6ecjItDUlnXALjobOJcemZ6hVJgldhNVw9MqfXNnvW1Xo8fEwPmmV2+Tk6ygGCePi8TH5NPNcoDg46A2aBwTWzn4/f1mFmlrK6yWBW8sD1NF3FaCGfFXcNZ/Krrv4IN1DYmXfZXZc9Q7YPDyFM9/zqYt4SJFWIQRZH/MaJunuT7AkdZAkKsH/F1gLuL61JckfGwE+qDOsw==; X-Yahoo-Newman-Id: 913002.44885.bm@smtp114.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 4W1y5scVM1mWdUjjbSPD0mNYHMnrgb0UJamVkY92G51N.ZM u2sVObsZ.pzHkzGCXcT7CMi3TEQfA5AhKNM.tLXERW.izc_1ICQRDHEMW5dQ 42XHas_SaWNlMC636OI0A94K1jiAAdPUjWor69ImBDzc1w2_dP3u.pGTGMhQ NoHPEkLasdYNdNtV2TqRrPVn0DWSdyPIa0vpO1tq6hIef.etBVH2mWMaLxGi e82FmK64i7fAQMHV6YgNLQR6p21NtWGTiaxTpPhc3yudp5KRZHLyO.8ecdQl 7mXtZJouMlU.AnZc17m3rHp9Qq096AHyxDSzslrlLl53DyseVxx5rD2kF6XF 9pOEYTwknj4ikDRCITMzhV_kmUcuqw87E0ubZE8ah_nhe7bUJNCTVuh717uL zfdUVmLqzSwFeToj3NdYGVIc1x3lcixKAcDQo4QpMorrDJ_xOfIk8Y46hYfD vKHhd4xlRT3fdeRWFyfRntwgXrYLnTUJ57ZS.ULHX2AWMQSFcmzXVtzDdbLi fmqQ7cDSvDf94n6t5_RWhgmsKv9srww-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: From: Oliver Kiddle References: To: Zsh-Users List Subject: Re: Function or Alias - Does it matter? MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7707.1416387563.1@thecus.kiddle.eu> Date: Wed, 19 Nov 2014 09:59:23 +0100 Message-ID: <7708.1416387563@thecus.kiddle.eu> TJ Luoma wrote: > function if they do the same thing? > > For example, these are (as far as I know) functionally identical: > > function timestamp_r { strftime "%Y/%m/%d at %-I:%M:%S %p" > "$EPOCHSECONDS" } > > alias timestamp_r='strftime "%Y/%m/%d at %-I:%M:%S %p" "$EPOCHSECONDS"' > > Is there any reason to prefer one or the other? If you find your function finishes by passing "$@" as the last argument to whatever command it is, then there's a good chance that an alias will suffice. Note that (unless you unsetopt completealiases), completion after an alias will look at the alias definition so with, e.g: alias ll='ls -lFb' ll - this will still complete options to ls. With the function equivalent that won't work without an explicit compdef. Functions can be more flexible with their arguments. For example, the following slight modification to your function makes EPOCHSECONDS merely a default if you don't specify a different time. This is not possible with an alias: function timestamp_r { strftime "%Y/%m/%d at %-I:%M:%S %p" "${1:-$EPOCHSECONDS}" } Oliver