[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] getting bash sh to read in personal config
From: |
doark |
Subject: |
Re: [Help-bash] getting bash sh to read in personal config |
Date: |
Fri, 9 Oct 2015 21:44:28 -0400 |
> On Wed, Sep 30, 2015 at 01:28:27PM -0400, David Niklas wrote:
> > As you may or may not know, fvwm uses a config file for menus and
> > all menu items are executed via sh (or so I beileve). I wanted to
> > define some variables for arguments such as a font to keep the size
> > of the menu down, and make accessing these long arguments easier I
> > want to place them in a file.
>
> I truly believe it would be best to put
> the commands you want to run directly into your ~/.fvwm/.fvwm2rc file.
> Tracking stuff down (when it inevitably needs to change) across
> multiple files is no fun.
>
But if you want your terminal to have a black background and white
foreground and use a particular font (I don't always code in X), then it
is far easier to either make an alias, or use variables to store the
extra args/options as opposed to having to copy and paste the same
values over and over again into .fvwmrc, you see, the fvwm menu contains
several commands, and I intend to add more, where the command is
executed in the terminal which requires that I set the terminals
settings many (think 20+) times. The same thing applies to other
commands, which for brevity, I'm omitting.
This way, I always have a global environment for my user which I can
depend on, cross application, if I set it up right.
> That said,
>
> When bash is started non-interactively, to run a shell
> script, for example, it looks for the variable BASH_ENV in the
> environment, expands its value if it appears there, and uses the
> expanded value as the name of a file to read and execute.
>
> And,
>
> ENV Similar to BASH_ENV; used when the shell is invoked
> in POSIX mode.
For posterity's sake I set this in /etc/profile to
export ENV=~/.profile
export BASH_ENV=~/.profile
And it works, though I must tell plain interactive bash to use it as
well. Please note that any user that has rw access to a processes home
dir can change the .profile file to contain evil things; so this may
not be suitable for some environments.
I will not be changing this to my main .bashrc file which has this
statement before any commands for interactive shells.
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
zsh and bash both support this test when invoked as sh, but busybox
does not, so I don't think that this is a wholly reliable test and I
might ask later about this after researching the matter.
For the time being I will just source this file before my main .bashrc
file.
Thanks, David