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 1430-1435 Link Here
1430
.if t \f(CW".:~:/usr"\fP.
1430
.if t \f(CW".:~:/usr"\fP.
1431
.if n ".:~:/usr".
1431
.if n ".:~:/usr".
1432
.TP
1432
.TP
1433
.B CMD
1434
Is set before a command is run, each array field corresponds to one argument
1435
of the command line. It is intended to be used in PREEXEC_COMMAND scripts.
1436
In case of pipe-commands the command line of the last command in the
1437
pipe-chain is stored in CMD.
1438
.TP
1433
.B COLUMNS
1439
.B COLUMNS
1434
Used by the \fBselect\fP builtin command to determine the terminal width
1440
Used by the \fBselect\fP builtin command to determine the terminal width
1435
when printing selection lists.  Automatically set upon receipt of a SIGWINCH.
1441
when printing selection lists.  Automatically set upon receipt of a SIGWINCH.
Lines 1690-1695 Link Here
1690
.if n \fIset -o posix\fP
1698
.if n \fIset -o posix\fP
1691
had been executed.
1699
had been executed.
1692
.TP
1700
.TP
1701
.B PREEXEC_COMMAND
1702
If set, the value is executed as a command prior to executing entered
1703
commands in interactive mode
1704
.TP
1693
.B PROMPT_COMMAND
1705
.B PROMPT_COMMAND
1694
If set, the value is executed as a command prior to issuing each primary
1706
If set, the value is executed as a command prior to issuing each primary
1695
prompt.
1707
prompt.
(-)bash-origfiles/doc/bashref.texi (+10 lines)
Lines 3939-3944 Link Here
3939
A colon-separated list of directories used as a search path for
3939
A colon-separated list of directories used as a search path for
3940
the @code{cd} builtin command.
3940
the @code{cd} builtin command.
3941
3941
3942
@item CMD
3943
Is set before a command is run, each array field corresponds to one argument
3944
of the command line. It is intended to be used in @env{PREEXEC_COMMAND} scripts.
3945
In case of pipe-commands the command line of the last command in the
3946
pipe-chain is stored in @env{CMD}.
3947
3942
@item HOME
3948
@item HOME
3943
The current user's home directory; the default for the @code{cd} builtin
3949
The current user's home directory; the default for the @code{cd} builtin
3944
command.
3950
command.
Lines 4296-4301 Link Here
4296
The process @sc{id} of the shell's parent process.  This variable
4302
The process @sc{id} of the shell's parent process.  This variable
4297
is readonly.
4303
is readonly.
4298
4304
4305
@item PREEXEC_COMMAND
4306
If set, the value is executed as a command prior to executing entered
4307
commands in interactive mode.
4308
4299
@item PROMPT_COMMAND
4309
@item PROMPT_COMMAND
4300
If set, the value is interpreted as a command to execute
4310
If set, the value is interpreted as a command to execute
4301
before the printing of each primary prompt (@env{$PS1}).
4311
before the printing of each primary prompt (@env{$PS1}).
(-)bash-origfiles/eval.c (+68 lines)
Lines 139-144 Link Here
139
	      current_command_number++;
139
	      current_command_number++;
140
140
141
	      executing = 1;
141
	      executing = 1;
142
	      export_command(current_command);
143
	      preexec_command ();
142
	      stdin_redir = 0;
144
	      stdin_redir = 0;
143
	      execute_command (current_command);
145
	      execute_command (current_command);
144
146
Lines 222-227 Link Here
222
  return (r);
224
  return (r);
223
}
225
}
224
226
227
/* This is where PREEXEC_COMMAND is executed */
228
229
void
230
preexec_command ()
231
{
232
  char *command_to_execute;
233
234
  need_here_doc = 0;
235
  run_pending_traps ();
236
237
  if (interactive && bash_input.type != st_string)
238
    {
239
      command_to_execute = get_string_value ("PREEXEC_COMMAND");
240
      if (command_to_execute)
241
	execute_prompt_command (command_to_execute);
242
243
      if (running_under_emacs == 2)
244
	send_pwd_to_eterm ();	/* Yuck */
245
    }
246
}
247
225
/* Read and parse a command, returning the status of the parse.  The command
248
/* Read and parse a command, returning the status of the parse.  The command
226
   is left in the globval variable GLOBAL_COMMAND for use by reader_loop.
249
   is left in the globval variable GLOBAL_COMMAND for use by reader_loop.
227
   This is where the shell timeout code is executed. */
250
   This is where the shell timeout code is executed. */
Lines 268-270 Link Here
268
293
269
  return (result);
294
  return (result);
270
}
295
}
296
297
/* export_command makes an array "CMD" and fills its fields
298
   with the command line of "command" (only for cm_simple,
299
   for cm_connection the last command in the chain is used */
300
301
void
302
export_command (command)
303
	COMMAND *command;
304
{
305
	int i = 0;
306
	SHELL_VAR *cmd_var;
307
	ARRAY *cmd_array;
308
	WORD_LIST *list;
309
310
	if(command->type == cm_simple)
311
		list = command->value.Simple->words;
312
	else if(command->type == cm_connection)
313
	{
314
		if(!command->value.Connection->second)
315
			return;
316
		if(command->flags == CMD_FORCE_SUBSHELL)
317
			command = command->value.Connection->first;
318
			return;
319
		while(command->type == cm_connection)
320
			command = command->value.Connection->second;
321
		if(command->type == cm_simple)
322
			list = command->value.Simple->words;
323
		else
324
			return;
325
	}
326
	else
327
		return;
328
	
329
	cmd_var = make_new_array_variable ("CMD");
330
	cmd_array = array_cell (cmd_var);
331
332
	while(list)
333
	{
334
		array_insert (cmd_array, i, list->word->word);
335
		list=list->next;
336
		i++;
337
	}
338
339
	VSETATTR (cmd_var, (att_exported));
340
}
(-)bash-origfiles/externs.h (+2 lines)
Lines 62-67 Link Here
62
extern int reader_loop __P((void));
62
extern int reader_loop __P((void));
63
extern int parse_command __P((void));
63
extern int parse_command __P((void));
64
extern int read_command __P((void));
64
extern int read_command __P((void));
65
extern void export_command __P((COMMAND *));
66
extern void preexec_command __P((void)); 
65
67
66
/* Functions from braces.c. */
68
/* Functions from braces.c. */
67
#if defined (BRACE_EXPANSION)
69
#if defined (BRACE_EXPANSION)

Return to bug 31414