lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, 6 Mar 2012 23:55:43 -0500
Benjamin Ong <human_pitchpipe@hotmail.com> wrote:

> 
> hi Steve,
> 
> By default, non-interactive shells do not
> expand aliases.  We have some LMOD modules 
> (written in lua) whose functionality depends
> on defining aliases.  Ideally, a lua command
> can be issued at the start of the modulefile
> to enable aliases.  It certainly must be possible,
> because environment variables in the parent shell
> can be set using lua.
> 
> There are three other workarounds we have considered:
> (1) educate users that every job script that
> requires aliases must include the command
> shopt -s expand_aliases
> (2) educate users to use interactive shells for their 
> job scripts if aliases are required.
> (3) globally set expand_aliases to true.
> 
> None of these options hold much appeal presently.
> 
> thanks
> 
> ~ ben

So howbout this:

Instead of doing:

./my_lmod_program.lua

make this my_lmod_script.sh

#!/bin/bash
shopt -s expand_aliases
./my_lmod_program.lua

I do this all the time. I create a simple shellscript that sets and
exports all necessary environment variables, goes to the proper
directory, and then runs the real program. I often use one shellscript
to initialize a whole bunch of little programs (for instance, a
shellscripted Domain Specific Language (DSL)). Let's say my shellscript
is called do.sh:

./do.sh show_menu.lua
./do.sh get_user_keystroke.lua
./do.sh key_to_command.lua
./do.sh run_command.lua

The preceding is a little contrived, but you know what I mean.

SteveT