summaryrefslogtreecommitdiff
path: root/debian/patches/command-not-found.dpatch
blob: b1feb22172c58d37fd03dc1988d189109f810609 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! /bin/sh -e

if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="-d $3"
elif [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch) patch $pdir -f --no-backup-if-mismatch -p1 < $0;;
    -unpatch) patch $pdir -f --no-backup-if-mismatch -R -p1 < $0;;
    *)
	echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
	exit 1
esac
exit 0

# DP: Add command_not_found_handle in interactive non POSIX mode

--- bash/execute_cmd.c~	2004-08-28 14:43:04.000000000 +0200
+++ bash/execute_cmd.c	2004-08-28 14:54:57.000000000 +0200
@@ -3615,8 +3615,26 @@
 
       if (command == 0)
 	{
-	  internal_error (_("%s: command not found"), pathname);
-	  exit (EX_NOTFOUND);	/* Posix.2 says the exit status is 127 */
+	  SHELL_VAR *f, *v;
+	  WORD_LIST *cmdlist;
+	  WORD_DESC *w;
+	  int fval;
+	  if( (posixly_correct || interactive_shell == 0) ||
+	      (f = find_function ("command_not_found_handle")) == 0)
+	    {
+	      internal_error (_("%s: command not found"), pathname);
+	      exit (EX_NOTFOUND);     /* Posix.2 says the exit status is 127 */
+	    }
+	  w = make_word("command_not_found_handle");
+	  cmdlist = make_word_list(w, (WORD_LIST*)NULL);
+
+	  w = make_word(pathname);
+	  cmdlist->next = make_word_list(w, (WORD_LIST*)NULL);
+	   
+	  fval = execute_shell_function (f, cmdlist);
+	  if (fval == EX_NOTFOUND)
+	    internal_error (_("%s: command not found"), pathname);
+	  exit(fval);
 	}
 
       /* Execve expects the command name to be in args[0].  So we
--- bash/doc/bash.1~	2004-08-06 08:01:10.000000000 +0200
+++ bash/doc/bash.1	2004-08-28 15:03:13.000000000 +0200
@@ -1972,6 +1972,13 @@
 .B %
 job identifier.
 .TP
+.B command_not_found_handle
+The name of a shell function to be called if a command cannot be
+found. The return value of this function should be 0, if the command
+is available after execution of the function, otherwise 127 (EX_NOTFOUND).
+Enabled only in interactive, non POSIX mode shells. This is a Debian
+extension.
+.TP
 .B histchars
 The two or three characters which control history expansion
 and tokenization (see