bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

errno in PS1 variable [patch included]


From: Yonatan Bokovza
Subject: errno in PS1 variable [patch included]
Date: Sun, 25 Nov 2001 11:34:24 +0200

I thought I could gain a lot if the last
errno could be a part of my prompt.
The following patch makes this
PS1="\E "
show the last errno as the prompt.

Environment:
~/work/bash$> bash --version
bash --version
GNU bash, version 2.05a.0(1)-release (i386--freebsd4.4)
Copyright 2001 Free Software Foundation, Inc.
~/work/bash$> uname -a
FreeBSD Temujin.xpert.com 4.4-STABLE FreeBSD 4.4-STABLE #6: Thu Nov 22
12:51:59
IST 2001     root@Temujin.xpert.com:/usr/obj/usr/src/sys/TEMUJIN  i386


Best Regards, 

Yonatan Bokovza
IT Security Consultant
Xpert Systems


--- parse.y.orig        Tue Oct 30 18:23:35 2001
+++ parse.y     Fri Nov 23 18:11:42 2001
@@ -3922,6 +3922,11 @@
              temp[1] = '\0';
              goto add_string;
 
+           case 'E':           /* \E in PS will output last errno */
+             temp = (char *)xmalloc (8);
+             sprintf (temp, "%d", last_command_exit_value);
+             goto add_string;
+
            default:
              temp = (char *)xmalloc (3);
              temp[0] = '\\';



reply via email to

[Prev in Thread] Current Thread [Next in Thread]