Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 31414 | Differences between
and this patch

Collapse All | Expand All

(-)bash-origfiles/doc/bash.1 (+10 lines)
Lines 1550-1555 Link Here
1550
.if t \f(CW".:~:/usr"\fP.
1550
.if t \f(CW".:~:/usr"\fP.
1551
.if n ".:~:/usr".
1551
.if n ".:~:/usr".
1552
.TP
1552
.TP
1553
.B PREEXEC_CMD
1554
Is set before a command is run, each array field corresponds to one argument
1555
of the command line. It is intended to be used in PREEXEC_COMMAND scripts.
1556
In case of pipe-commands the command line of the last command in the
1557
pipe-chain is stored in PREEXEC_CMD.
1558
.TP
1553
.B COLUMNS
1559
.B COLUMNS
1554
Used by the \fBselect\fP builtin command to determine the terminal width
1560
Used by the \fBselect\fP builtin command to determine the terminal width
1555
when printing selection lists.  Automatically set upon receipt of a SIGWINCH.
1561
when printing selection lists.  Automatically set upon receipt of a SIGWINCH.
Lines 1834-1839 Link Here
1834
.if n \fIset -o posix\fP
1840
.if n \fIset -o posix\fP
1835
had been executed.
1841
had been executed.
1836
.TP
1842
.TP
1843
.B PREEXEC_COMMAND
1844
If set, the value is executed as a command prior to executing entered
1845
commands in interactive mode
1846
.TP
1837
.B PROMPT_COMMAND
1847
.B PROMPT_COMMAND
1838
If set, the value is executed as a command prior to issuing each primary
1848
If set, the value is executed as a command prior to issuing each primary
1839
prompt.
1849
prompt.
(-)bash-origfiles/doc/bashref.texi (+10 lines)
Lines 4178-4183 Link Here
4178
A colon-separated list of directories used as a search path for
4178
A colon-separated list of directories used as a search path for
4179
the @code{cd} builtin command.
4179
the @code{cd} builtin command.
4180
4180
4181
@item PREEXEC_CMD
4182
Is set before a command is run, each array field corresponds to one argument
4183
of the command line. It is intended to be used in @env{PREEXEC_COMMAND} scripts.
4184
In case of pipe-commands the command line of the last command in the
4185
pipe-chain is stored in @env{PREEXEC_CMD}.
4186
4181
@item HOME
4187
@item HOME
4182
The current user's home directory; the default for the @code{cd} builtin
4188
The current user's home directory; the default for the @code{cd} builtin
4183
command.
4189
command.
Lines 4619-4624 Link Here
4619
The process @sc{id} of the shell's parent process.  This variable
4625
The process @sc{id} of the shell's parent process.  This variable
4620
is readonly.
4626
is readonly.
4621
4627
4628
@item PREEXEC_COMMAND
4629
If set, the value is executed as a command prior to executing entered
4630
commands in interactive mode.
4631
4622
@item PROMPT_COMMAND
4632
@item PROMPT_COMMAND
4623
If set, the value is interpreted as a command to execute
4633
If set, the value is interpreted as a command to execute
4624
before the printing of each primary prompt (@env{$PS1}).
4634
before the printing of each primary prompt (@env{$PS1}).
(-)bash-origfiles/eval.c (+68 lines)
Lines 142-147 Link Here
142
	      current_command_number++;
142
	      current_command_number++;
143
143
144
	      executing = 1;
144
	      executing = 1;
145
	      export_command(current_command);
146
	      preexec_command ();
145
	      stdin_redir = 0;
147
	      stdin_redir = 0;
146
	      execute_command (current_command);
148
	      execute_command (current_command);
147
149
Lines 226-231 Link Here
226
  return (r);
228
  return (r);
227
}
229
}
228
230
231
/* This is where PREEXEC_COMMAND is executed */
232
233
void
234
preexec_command ()
235
{
236
  char *command_to_execute;
237
238
  need_here_doc = 0;
239
  run_pending_traps ();
240
241
  if (interactive && bash_input.type != st_string)
242
    {
243
      command_to_execute = get_string_value ("PREEXEC_COMMAND");
244
      if (command_to_execute)
245
	execute_prompt_command (command_to_execute);
246
247
      if (running_under_emacs == 2)
248
	send_pwd_to_eterm ();	/* Yuck */
249
    }
250
}
251
229
/* Read and parse a command, returning the status of the parse.  The command
252
/* Read and parse a command, returning the status of the parse.  The command
230
   is left in the globval variable GLOBAL_COMMAND for use by reader_loop.
253
   is left in the globval variable GLOBAL_COMMAND for use by reader_loop.
231
   This is where the shell timeout code is executed. */
254
   This is where the shell timeout code is executed. */
Lines 272-274 Link Here
272
295
273
  return (result);
296
  return (result);
274
}
297
}
298
299
/* export_command makes an array "PREEXEC_CMD" and fills its fields
300
   with the command line of "command" (only for cm_simple,
301
   for cm_connection the last command in the chain is used */
302
303
void
304
export_command (command)
305
	COMMAND *command;
306
{
307
	int i = 0;
308
	SHELL_VAR *cmd_var;
309
	ARRAY *cmd_array;
310
	WORD_LIST *list;
311
312
	if(command->type == cm_simple)
313
		list = command->value.Simple->words;
314
	else if(command->type == cm_connection)
315
	{
316
		if(!command->value.Connection->second)
317
			return;
318
		if(command->flags == CMD_FORCE_SUBSHELL)
319
			command = command->value.Connection->first;
320
			return;
321
		while(command->type == cm_connection)
322
			command = command->value.Connection->second;
323
		if(command->type == cm_simple)
324
			list = command->value.Simple->words;
325
		else
326
			return;
327
	}
328
	else
329
		return;
330
	
331
	cmd_var = make_new_array_variable ("PREEXEC_CMD");
332
	cmd_array = array_cell (cmd_var);
333
334
	while(list)
335
	{
336
		array_insert (cmd_array, i, list->word->word);
337
		list=list->next;
338
		i++;
339
	}
340
341
	VSETATTR (cmd_var, (att_exported));
342
}
(-)bash-origfiles/externs.h (+2 lines)
Lines 84-89 Link Here
84
extern int reader_loop __P((void));
84
extern int reader_loop __P((void));
85
extern int parse_command __P((void));
85
extern int parse_command __P((void));
86
extern int read_command __P((void));
86
extern int read_command __P((void));
87
extern void export_command __P((COMMAND *));
88
extern void preexec_command __P((void)); 
87
89
88
/* Functions from braces.c. */
90
/* Functions from braces.c. */
89
#if defined (BRACE_EXPANSION)
91
#if defined (BRACE_EXPANSION)

Return to bug 31414