zsh-users
 help / color / mirror / code / Atom feed
From: TJ Luoma <luomat@gmail.com>
To: Zsh-Users List <zsh-users@zsh.org>
Subject: How do you decide whether to make something a function or a script?
Date: Sat, 8 Sep 2018 21:22:17 -0400	[thread overview]
Message-ID: <CADjGqHuK2oV3VzjHO0H5+FHJXC85HmysL9yPRjS-ESLhBcC3FA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 743 bytes --]

I've been moving some of my more elaborate functions into their own files
and using the autoload feature to import them into other scripts.

But it's gotten me to wonder:

Why make any functions at all? Why not just make them all scripts? If they
are scripts in the $PATH then you can just call them by name and they work
in the login shell or in scripts. If they are functions, you have to
autoload them first.

So I've gotten to wonder… what makes you make something a function vs a
script?

TjL

--
TJ Luoma
TJ @ MacStories <http://www.macstories.net/author/tjluoma/>
Personal Website: luo.ma <http://luo.ma/> (aka RhymesWithDiploma.com
<http://rhymeswithdiploma.com/>)
Twitter: @tjluoma <http://twitter.com/tjluoma>

             reply	other threads:[~2018-09-09  1:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-09  1:22 TJ Luoma [this message]
2018-09-09  1:55 ` Grant Taylor
2018-09-09  2:21   ` Daniel Shahaf
2018-09-09  2:51     ` Grant Taylor
2018-09-09 19:34     ` TJ Luoma
2018-09-09 22:54       ` Bart Schaefer
2018-09-09  3:24 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADjGqHuK2oV3VzjHO0H5+FHJXC85HmysL9yPRjS-ESLhBcC3FA@mail.gmail.com \
    --to=luomat@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).