Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 58338 Details for
Bug 31414
bash enhancement(patch) to have zsh(,tcsh,..) PREEXEC like function
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
new preexec patch
bash-preexec-gentoo.diff (text/plain), 4.66 KB, created by
Andrea Barisani (RETIRED)
on 2005-05-08 04:14:15 UTC
(
hide
)
Description:
new preexec patch
Filename:
MIME Type:
Creator:
Andrea Barisani (RETIRED)
Created:
2005-05-08 04:14:15 UTC
Size:
4.66 KB
patch
obsolete
>diff -ruN bash-origfiles/doc/bash.1 bash-preexec/doc/bash.1 >--- bash-origfiles/doc/bash.1 2004-07-12 17:27:08.000000000 +0200 >+++ bash-preexec/doc/bash.1 2005-05-08 12:45:32.000000000 +0200 >@@ -1550,6 +1550,12 @@ > .if t \f(CW".:~:/usr"\fP. > .if n ".:~:/usr". > .TP >+.B PREEXEC_CMD >+Is set before a command is run, each array field corresponds to one argument >+of the command line. It is intended to be used in PREEXEC_COMMAND scripts. >+In case of pipe-commands the command line of the last command in the >+pipe-chain is stored in PREEXEC_CMD. >+.TP > .B COLUMNS > Used by the \fBselect\fP builtin command to determine the terminal width > when printing selection lists. Automatically set upon receipt of a SIGWINCH. >@@ -1834,6 +1840,10 @@ > .if n \fIset -o posix\fP > had been executed. > .TP >+.B PREEXEC_COMMAND >+If set, the value is executed as a command prior to executing entered >+commands in interactive mode >+.TP > .B PROMPT_COMMAND > If set, the value is executed as a command prior to issuing each primary > prompt. >diff -ruN bash-origfiles/doc/bashref.texi bash-preexec/doc/bashref.texi >--- bash-origfiles/doc/bashref.texi 2004-06-26 20:26:07.000000000 +0200 >+++ bash-preexec/doc/bashref.texi 2005-05-08 12:45:32.000000000 +0200 >@@ -4178,6 +4178,12 @@ > A colon-separated list of directories used as a search path for > the @code{cd} builtin command. > >+@item PREEXEC_CMD >+Is set before a command is run, each array field corresponds to one argument >+of the command line. It is intended to be used in @env{PREEXEC_COMMAND} scripts. >+In case of pipe-commands the command line of the last command in the >+pipe-chain is stored in @env{PREEXEC_CMD}. >+ > @item HOME > The current user's home directory; the default for the @code{cd} builtin > command. >@@ -4619,6 +4625,10 @@ > The process @sc{id} of the shell's parent process. This variable > is readonly. > >+@item PREEXEC_COMMAND >+If set, the value is executed as a command prior to executing entered >+commands in interactive mode. >+ > @item PROMPT_COMMAND > If set, the value is interpreted as a command to execute > before the printing of each primary prompt (@env{$PS1}). >diff -ruN bash-origfiles/eval.c bash-preexec/eval.c >--- bash-origfiles/eval.c 2003-12-19 05:44:15.000000000 +0100 >+++ bash-preexec/eval.c 2005-05-08 12:46:38.000000000 +0200 >@@ -142,6 +142,8 @@ > current_command_number++; > > executing = 1; >+ export_command(current_command); >+ preexec_command (); > stdin_redir = 0; > execute_command (current_command); > >@@ -226,6 +228,27 @@ > return (r); > } > >+/* This is where PREEXEC_COMMAND is executed */ >+ >+void >+preexec_command () >+{ >+ char *command_to_execute; >+ >+ need_here_doc = 0; >+ run_pending_traps (); >+ >+ if (interactive && bash_input.type != st_string) >+ { >+ command_to_execute = get_string_value ("PREEXEC_COMMAND"); >+ if (command_to_execute) >+ execute_prompt_command (command_to_execute); >+ >+ if (running_under_emacs == 2) >+ send_pwd_to_eterm (); /* Yuck */ >+ } >+} >+ > /* Read and parse a command, returning the status of the parse. The command > is left in the globval variable GLOBAL_COMMAND for use by reader_loop. > This is where the shell timeout code is executed. */ >@@ -272,3 +295,48 @@ > > return (result); > } >+ >+/* export_command makes an array "PREEXEC_CMD" and fills its fields >+ with the command line of "command" (only for cm_simple, >+ for cm_connection the last command in the chain is used */ >+ >+void >+export_command (command) >+ COMMAND *command; >+{ >+ int i = 0; >+ SHELL_VAR *cmd_var; >+ ARRAY *cmd_array; >+ WORD_LIST *list; >+ >+ if(command->type == cm_simple) >+ list = command->value.Simple->words; >+ else if(command->type == cm_connection) >+ { >+ if(!command->value.Connection->second) >+ return; >+ if(command->flags == CMD_FORCE_SUBSHELL) >+ command = command->value.Connection->first; >+ return; >+ while(command->type == cm_connection) >+ command = command->value.Connection->second; >+ if(command->type == cm_simple) >+ list = command->value.Simple->words; >+ else >+ return; >+ } >+ else >+ return; >+ >+ cmd_var = make_new_array_variable ("PREEXEC_CMD"); >+ cmd_array = array_cell (cmd_var); >+ >+ while(list) >+ { >+ array_insert (cmd_array, i, list->word->word); >+ list=list->next; >+ i++; >+ } >+ >+ VSETATTR (cmd_var, (att_exported)); >+} >diff -ruN bash-origfiles/externs.h bash-preexec/externs.h >--- bash-origfiles/externs.h 2004-04-13 05:30:08.000000000 +0200 >+++ bash-preexec/externs.h 2005-05-08 12:45:32.000000000 +0200 >@@ -84,6 +84,8 @@ > extern int reader_loop __P((void)); > extern int parse_command __P((void)); > extern int read_command __P((void)); >+extern void export_command __P((COMMAND *)); >+extern void preexec_command __P((void)); > > /* Functions from braces.c. */ > #if defined (BRACE_EXPANSION)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 31414
:
58049
| 58338