Date: Wed, 21 Jul 2010 20:17:36 +0400 From: Anonymous <swell.k@gmail.com> To: jimbob palmer <jimbobpalmer@gmail.com> Cc: freebsd-questions@freebsd.org Subject: Re: Bash logging: two questions Message-ID: <866308stb3.fsf@gmail.com> In-Reply-To: <AANLkTilOa7V0TQ8MlI9fIs_f-ZtP2Zwz_LuMALvMyMtD@mail.gmail.com> (jimbob palmer's message of "Wed, 21 Jul 2010 16:40:37 %2B0200") References: <AANLkTilOa7V0TQ8MlI9fIs_f-ZtP2Zwz_LuMALvMyMtD@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
jimbob palmer <jimbobpalmer@gmail.com> writes: > Hello, > > I would like to run a bash script but to log output and exit codes. > Essentially I would like to run the script with bash -x, but for that > output to the log to go to a file, and the normal output as from > running a normal script to go to the terminal. Dunno about bash but in zsh it's easy #! /usr/bin/env zsh PS4='+%i:%N:%?> ' exec 2>trace.log set -x # here goes the main script foo=5 bar=$(date) echo foo=$foo, $bar false echo It should work in sh(1) except you'll not see exit values in prompt. Seems like bash doesn't have tcsh-like features: `%?' and printexitvalue. I guess you'll have to write your own wrapper to put `$?' into stderr after each command. > My second question is about history. Bash has a -h option to remember > the location of commands as they are looked up. Is it possible for > this to be recorded in the history? e.g. if I run ls, it would record > /bin/ls to the bash history file. If bash has smth like zshaddhistory() it'd be easy...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?866308stb3.fsf>