Filename extension for LFE shell scripts and default LFE shell commands

28 views
Skip to first unread message

Robert Virding

unread,
Feb 12, 2015, 11:16:04 AM2/12/15
to lisp-flavo...@googlegroups.com
We use the extension ".lfe" for LFE files. Which extension, if any, should we use for LFE shell scripts? It would only be a convention because I think when loading/running scripts we should give the whole name. We could have ".lfes" for an LFE script, or ".lsh" for LFE shell script (modelling sh)? Or perhaps do the same as sh and not have any convention at all? This would fit better in with having LFE scripts as executables.

One reason for my asking is that the question has arisen about how to allow the user to load a set of predefined shell functions. One simple way is to put them in an LFE shell script and do (run "script-file-name"). This way works but it is not automatic. We are adding a mechanism similar to what the erlang shell does, it uses functions in the module user_default. But it would be nice to be able to run any shell commands as well, and to allow it to be different for different shells! One way would be to look for a default shell script file and load it.

There are many alternatives: we could load a "~/.lfeshrc"; or a local ".lfeshrc"; or a local "user_default.???"; or a combination of these.

I will have the user_default module method fixed in a few days in the develop branch. Ideas and suggestions welcome,

Robert

Duncan McGreggor

unread,
Feb 12, 2015, 11:59:19 AM2/12/15
to lisp-flavo...@googlegroups.com
I've been thinking about one angle of this for a couple of days, too -- but not for shell files, for config files ...

Thoughts below.

On Thu, Feb 12, 2015 at 10:16 AM, Robert Virding <rvir...@gmail.com> wrote:
We use the extension ".lfe" for LFE files. Which extension, if any, should we use for LFE shell scripts?

I read through the whole thing, and to be honest, I think .lfe is really the best option. .lfe or nothing. This is what some other languages do, too. They don't have special treatment for a file as long as it's in the same language (regardless if it's used as a script or if it's a module).
 
It would only be a convention because I think when loading/running scripts we should give the whole name. We could have ".lfes" for an LFE script, or ".lsh" for LFE shell script (modelling sh)? Or perhaps do the same as sh and not have any convention at all? This would fit better in with having LFE scripts as executables.

One reason for my asking is that the question has arisen about how to allow the user to load a set of predefined shell functions. One simple way is to put them in an LFE shell script and do (run "script-file-name"). This way works but it is not automatic.

We could do something automatic for files with an extension (e.g., .lfe) and then, if the user opts to not have a file extension, they could put flags after the shebang line. LFE could look for those and run code as appropriate.
 
We are adding a mechanism similar to what the erlang shell does, it uses functions in the module user_default. But it would be nice to be able to run any shell commands as well, and to allow it to be different for different shells! One way would be to look for a default shell script file and load it.

There are many alternatives: we could load a "~/.lfeshrc"; or a local ".lfeshrc"; or a local "user_default.???"; or a combination of these.

Since we're starting to use the ~/.lfe/ directory, I'd vote for ~/.lfe/lfeshrc ... though we could always have a list of files that it checked (e.g., first one found wins).
 
I will have the user_default module method fixed in a few days in the develop branch. Ideas and suggestions welcome,

This is very cool! It will make creating tutorials for beginners much easier.

Thanks for doing this, Robert!

d
 

Robert

--
You received this message because you are subscribed to the Google Groups "Lisp Flavoured Erlang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lisp-flavoured-e...@googlegroups.com.
To post to this group, send email to lisp-flavo...@googlegroups.com.
Visit this group at http://groups.google.com/group/lisp-flavoured-erlang.
For more options, visit https://groups.google.com/d/optout.

arpunk

unread,
Feb 12, 2015, 4:29:57 PM2/12/15
to lisp-flavo...@googlegroups.com
On Thu, 12 Feb 2015 11:59:18 -0500,
Duncan McGreggor wrote:
> On Thu, Feb 12, 2015 at 10:16 AM, Robert Virding <rvir...@gmail.com> wrote:
>
> We use the extension ".lfe" for LFE files. Which extension, if
> any, should we use for LFE shell scripts?
>
> I read through the whole thing, and to be honest, I think .lfe is
> really the best option. .lfe or nothing. This is what some other
> languages do, too. They don't have special treatment for a file as
> long as it's in the same language (regardless if it's used as a
> script or if it's a module).  

I agree. There is no code difference between compiling a module,
loading it up on the shell, running on a terminal. Config files,
specially since lcfg was born, is another topic.

> Since we're starting to use the ~/.lfe/ directory, I'd vote for
> ~/.lfe/lfeshrc ... though we could always have a list of files that
> it checked (e.g., first one found wins).  

I vote for this aswell, it helps keeping everything under one single
directory.

My 2 cents.

Mason Staugler

unread,
Feb 12, 2015, 4:38:40 PM2/12/15
to lisp-flavo...@googlegroups.com, arp...@cryptolab.net
I like the default shell script idea! Since you can define functions in it, I think it'd be useful to source two different files; first ~/.lfe/whatever and then a local ./whatever. The former is for my personal preferences and the latter could be distributed with the code. (This would make user_default pointless.)

All the names of the files mentioned in the thread are correct-ish and I don't have a strong preference either way.

Duncan McGreggor

unread,
Feb 12, 2015, 4:58:26 PM2/12/15
to lisp-flavo...@googlegroups.com, arp...@cryptolab.net
On Thu, Feb 12, 2015 at 3:38 PM, Mason Staugler <ma...@staugler.net> wrote:
I like the default shell script idea! Since you can define functions in it, I think it'd be useful to source two different files; first ~/.lfe/whatever and then a local ./whatever.

Yup, this is what the lcfg library does for the lfe.config file: looks for ./lfe.config first, and if that's not found, looks for ~/.lfe/lfe.config, allowing individual projects to override global user config settings.

d
 
The former is for my personal preferences and the latter could be distributed with the code. (This would make user_default pointless.)

All the names of the files mentioned in the thread are correct-ish and I don't have a strong preference either way.

--

Mason Staugler

unread,
Feb 12, 2015, 5:06:57 PM2/12/15
to lisp-flavo...@googlegroups.com, arp...@cryptolab.net
I wasn't aware of lcfg. I'll mess around with it later, but... I think these scripts should be normal LFE files, with the ability to use the defun macro, for instance.

Duncan McGreggor

unread,
Feb 12, 2015, 5:21:53 PM2/12/15
to lisp-flavo...@googlegroups.com, arpunk
Yeah, my bad for muddying the contextual waters -- lcfg is mostly LFE data (it does support *some* code evaluation). What we're talking about in this thread is very different that configuration; essentially the code that one would write in a REPL.

d

On Thu, Feb 12, 2015 at 4:06 PM, Mason Staugler <ma...@staugler.net> wrote:
I wasn't aware of lcfg. I'll mess around with it later, but... I think these scripts should be normal LFE files, with the ability to use the defun macro, for instance.

--

Robert Virding

unread,
Feb 13, 2015, 4:48:39 PM2/13/15
to lisp-flavo...@googlegroups.com, arp...@cryptolab.net
I was wondering about the filename extensions because .lfe files and LFE shell script files are different: .lfe files contain module definitions while the shell script files contain LFE shell commands. With a #! /usr/env/lfe on the first line the shell script files are executable in which case you probably don't want an extension. lfec is a good example of this. I imagine that lfescript files will be become less used now.

 How about we say that there is no predefined extension on the script files but if you want to add one then a *suggestion* is .lfesh?

I am working on importing the user_default module. I have modified Mason's PR so that shell local functions shadow those from user_default as I think this is more useful. I thought that while I was at it I could also execute the scripts ~/.lfe/lfesh and ./lfesh. Maybe we could also have a ~/.lfesh but this might be too much. :-) Anyway I was thinking about which order they should be loaded. My thought is that functions in ./lfesh shadow ~/.lfe/lfesh shadow user_default module shadow the predefined shell functions. This seems the most reasonable. And in all cases the functions are loaded at shell start time, even those in user_default module. The lfesh files are shell script so they can do things as well. They will be loaded/executed first ~/.lfe/lfesh then ./lfesh.

The built-in shell commands cannot be redefined, though you can define macros which expand to them.

That is my plan currently. Comments thoughts ideas? Do we like the filename lfesh or should it be something else?

Robert


On Thursday, February 12, 2015 at 11:21:53 PM UTC+1, Duncan McGreggor wrote:
Yeah, my bad for muddying the contextual waters -- lcfg is mostly LFE data (it does support *some* code evaluation). What we're talking about in this thread is very different that configuration; essentially the code that one would write in a REPL.

d
On Thu, Feb 12, 2015 at 4:06 PM, Mason Staugler <ma...@staugler.net> wrote:
I wasn't aware of lcfg. I'll mess around with it later, but... I think these scripts should be normal LFE files, with the ability to use the defun macro, for instance.

--
You received this message because you are subscribed to the Google Groups "Lisp Flavoured Erlang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lisp-flavoured-erlang+unsub...@googlegroups.com.
To post to this group, send email to lisp-flavoured-erlang@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages