tags:

views:

67

answers:

4

I'm on a shared webhost where I don't have permission to edit the global bash configuration file at /ect/bashrc. Unfortunately there is one line in the global file, mesg y, which puts the terminal in tty mode and makes scp and similar commands unavailable. My local ~./bashrc includes the global file as a source, like so:

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

My current workaround uses grep to output the global file, sans offending line, into a local file and use that as a source.

# Source global definitions
if [ -f /etc/bashrc ]; then
    grep -v mesg /etc/bashrc > ~/.bash_global
    . ~/.bash_global
fi

Is there a way to do include a grepped file like this without the intermediate step of creating an actual file? Something like this?

. grep -v mesg /etc/bashrc > ~/.bash_global
+1  A: 

I suggest to call mesg n :)

Drakosha
Calling `mesg n` after `mesg y` has been called globally still seems to force it into tty mode. I'm still getting `stdin: is not a tty` as an error…
Andrew
A: 

From memory, but something like

grep -v mesg /etc/bashrc | eval

should do the trick

Since i'm not sure eval will read stdin, you may need to rephrase it into

eval `grep -v mesg /etc/bashrc`
Isak Savo
But then how can I use that as a source with the `.` command? `. eval `stuff`` doesn't work…
Andrew
You don't need to source it.. eval will essentially do the same thing
Isak Savo
@isak, have you tried ? Create a simple file, called "testprofile" and inside it, `export TEST="something"`. now, do the `grep` and `eval` on `testprofile` and see if $TEST has the value.
ghostdog74
+2  A: 
. <(grep -v mesg /etc/bashrc)
Ignacio Vazquez-Abrams
That did it. I guess I was looking for the `<()` syntax.
Andrew
+4  A: 

lose the cat, its useless

source <(grep -v "mesg" /etc/bashrc)

the <() syntax is called process substitution.

ghostdog74