Search This Blog

Showing posts with label tcsh. Show all posts
Showing posts with label tcsh. Show all posts

Tuesday, July 09, 2013

setenv does not work from script

This post explains how to export a variable from a shell script to a tcsh parent shell.
 
consider the following script
hogwarts:~/x> cat setup_var.sh
#! /bin/tcsh -f

setenv a RAJU
echo $a
The executable bit is set on the script
hogwarts:~/x> chmod +x setup_var.sh
hogwarts:~/x> ls -al setup_var.sh
-rwxr-xr-x 1 rajulocal rajulocal 39 Jul  9 03:40 setup_var.sh
 
I am using the tcsh shell
hogwarts:~/x> echo $0
tcsh
When executed, it shows that the variable "a" is getting the correct value
hogwarts:~/x> ./setup_var.sh
RAJU
However, the variable is not exported to the parent shell even though setenv is used in the script.
hogwarts:~/x> echo $a
a: Undefined variable.
The solution is to "source the script" instead of "dot executing".
hogwarts:~/x> source setup_var.sh
RAJU
hogwarts:~/x> echo $a
RAJU
Voila! Now the variable "a" is exported to the parent shell.

Happy shell script hacking...

Monday, March 19, 2007

Disable system bell

1. The annoying system beep on tab completions can be disabled in Debian by adding the following lines to ~/.inputrc
$cat /home/rajulocal/.inputrc
# do not bell on tab-completion
set bell-style none
set bell-style visible
Unlike "xset b 0", the above hack works even if you are not running X.

Tested on Debian Etch (currently stable), on

$bash --version
GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

2. To disable the annoying bell sound in vim, gvim add the following line to ~/.vimrc
set vb t_vb=
More info for vim can be found at
:help visualbell
Tested on Debian Etch (currently stable), on vim 7.0.122

3. To disable the system bell sounds in tcsh, add the following line to ~/.cshrc
set nobeep
Tested it on Solaris 8, tcsh

Followers