Showing posts with label #Bash. Show all posts
Showing posts with label #Bash. Show all posts

2010-04-06

screen, tset, & emacs

Have had an issue w/ using emacs and screen together under Bash on a CentOS Linux host.

Problem

The problem manifests in two ways:

  1. font-lock-mode does not show in color, or in a limited subset of colors
  2. the Backspace key sends ^H but Emacs recognizes it as the "Help" invocation, and starts up the Help system

These problems have been showing up under screen but not when Emacs is started outside screen in the normal Bash shell.

Changing the TERM value and/or the Backspace in either or both of the terminal emulator software (PuTTY) did not fix the problem.

Setting the value of the TERM environment value in Bash had no apparent effect.

The Fix

Use tset to set the backspace character in the Bash shell before screen is started.

tset -e ^H

This works when TERM=vt102 in the Bash environment, and 'VT100+' is checked for the terminal type in PuTTY. Other term types may vary.

Note that for some reason the font-lock-mode problem went away, too.

2009-09-02

ASCII 0x07 - The BEL Character

The Visible bell mini-Howto describes the measures necessary to disable audio processing of the ASCII system bell (0x07 – BEL) character as a console "beep" in various shells and applications, including Bash and Emacs. under Linux.

2009-07-14

Bash PS1 Prompt Set [correction]

##
## Set that annoying Cygwin Bash prompt...;)
##
##   There was an error in this string the previously 
##   published version - here is the corrected version.
##   This is Bash shell script code; it should go in the
##   file ~/.bashrc in the user's HOME directory - it 
##   could also go in  /etc/bashrc
##
export PS1='\[\033[32m\]\u@\h: \[\033[33m\w\033[0m\]
\$'

2009-05-14

Standard I/O Redirection in Perl

This is an excerpt from the Perl manuals at perlDoc.perl.org concerning redirection of STDOUT and STDERR in Perl:

Because backticks do not affect standard error, use shell file descriptor syntax (assuming the shell supports this) if you care to address this. To capture a command's STDERR and STDOUT together:

$output = `cmd 2>&1`;

To capture a command's STDOUT but discard its STDERR:

$output = `cmd 2>/dev/null`;

To capture a command's STDERR but discard its STDOUT (ordering is important here):

$output = `cmd 2>&1 1>/dev/null`;

To exchange a command's STDOUT and STDERR in order to capture the STDERR but leave its STDOUT to come out the old STDERR:

$output = `cmd 3>&1 1>&2 2>&3 3>&-`;

To read both a command's STDOUT and its STDERR separately, it's easiest to redirect them separately to files, and then read from those files when the program is done:

system("program args 1>program.stdout 2>program.stderr");

The STDIN filehandle used by the command is inherited from Perl's STDIN. For example:

open BLAM, "blam" || die "Can't open: $!";
    open STDIN, "<&BLAM";

    print `sort`;

will print the sorted contents of the file "blam".

The I/O Operators manual also has some interesting information about standard file I/O in Perl.