summaryrefslogtreecommitdiff
path: root/system/ksh-openbsd/patches/09-nobeep_option.diff
blob: d34a43d63426bf710dd1b16cd5c3edb1aa7debfa (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
Index: emacs.c
===================================================================
RCS file: /cvs/src/bin/ksh/emacs.c,v
retrieving revision 1.46
diff -p -u -r1.46 emacs.c
--- emacs.c	10 Jun 2012 10:15:01 -0000	1.46
+++ emacs.c	26 Nov 2012 14:25:51 -0000
@@ -399,7 +399,8 @@ x_insert(int c)
 	 *  Should allow tab and control chars.
 	 */
 	if (c == 0) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return KSTD;
 	}
 	str[0] = c;
@@ -421,7 +422,8 @@ static int
 x_do_ins(const char *cp, int len)
 {
 	if (xep+len >= xend) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return -1;
 	}
 
@@ -477,7 +479,8 @@ x_del_back(int c)
 	int col = xcp - xbuf;
 
 	if (col == 0) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return KSTD;
 	}
 	if (x_arg > col)
@@ -493,7 +496,8 @@ x_del_char(int c)
 	int nleft = xep - xcp;
 
 	if (!nleft) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return KSTD;
 	}
 	if (x_arg > nleft)
@@ -592,7 +596,8 @@ x_bword(void)
 	char	*cp = xcp;
 
 	if (cp == xbuf) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return 0;
 	}
 	while (x_arg--) {
@@ -616,7 +621,8 @@ x_fword(void)
 	char	*cp = xcp;
 
 	if (cp == xep) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return 0;
 	}
 	while (x_arg--) {
@@ -706,7 +712,8 @@ x_mv_back(int c)
 	int col = xcp - xbuf;
 
 	if (col == 0) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return KSTD;
 	}
 	if (x_arg > col)
@@ -721,7 +728,8 @@ x_mv_forw(int c)
 	int nleft = xep - xcp;
 
 	if (!nleft) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return KSTD;
 	}
 	if (x_arg > nleft)
@@ -741,7 +749,8 @@ x_search_char_forw(int c)
 		if (c < 0 ||
 		    ((cp = (cp == xep) ? NULL : strchr(cp + 1, c)) == NULL &&
 		    (cp = strchr(xbuf, c)) == NULL)) {
-			x_e_putc(BEL);
+			if (!Flag(FNOBEEP))
+				x_e_putc(BEL);
 			return KSTD;
 		}
 	}
@@ -760,7 +769,8 @@ x_search_char_back(int c)
 			if (p-- == xbuf)
 				p = xep;
 			if (c < 0 || p == cp) {
-				x_e_putc(BEL);
+				if (!Flag(FNOBEEP))
+					x_e_putc(BEL);
 				return KSTD;
 			}
 			if (*p == c)
@@ -818,7 +828,8 @@ x_load_hist(char **hp)
 	int	oldsize;
 
 	if (hp < history || hp > histptr) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return;
 	}
 	x_histp = hp;
@@ -902,7 +913,8 @@ x_search_hist(int c)
 			/* add char to pattern */
 			/* overflow check... */
 			if (p >= &pat[sizeof(pat) - 1]) {
-				x_e_putc(BEL);
+				if (!Flag(FNOBEEP))
+					x_e_putc(BEL);
 				continue;
 			}
 			*p++ = c, *p = '\0';
@@ -943,7 +955,8 @@ x_search(char *pat, int sameline, int of
 			return i;
 		}
 	}
-	x_e_putc(BEL);
+	if (!Flag(FNOBEEP))
+		x_e_putc(BEL);
 	x_histp = histptr;
 	return -1;
 }
@@ -1082,11 +1095,13 @@ x_transpose(int c)
 	 * to the one they want.
 	 */
 	if (xcp == xbuf) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return KSTD;
 	} else if (xcp == xep || Flag(FGMACS)) {
 		if (xcp - xbuf == 1) {
-			x_e_putc(BEL);
+			if (!Flag(FNOBEEP))
+				x_e_putc(BEL);
 			return KSTD;
 		}
 		/* Gosling/Unipress emacs style: Swap two characters before the
@@ -1207,7 +1222,8 @@ x_abort(int c)
 static int
 x_error(int c)
 {
-	x_e_putc(BEL);
+	if (!Flag(FNOBEEP))
+		x_e_putc(BEL);
 	return KSTD;
 }
 
@@ -1624,7 +1640,8 @@ x_kill_region(int c)
 	char	*xr;
 
 	if (xmp == NULL) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return KSTD;
 	}
 	if (xmp > xcp) {
@@ -1646,7 +1663,8 @@ x_xchg_point_mark(int c)
 	char	*tmp;
 
 	if (xmp == NULL) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return KSTD;
 	}
 	tmp = xmp;
@@ -1749,7 +1767,8 @@ x_expand(int c)
 	    &start, &end, &words, &is_command);
 
 	if (nwords == 0) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return KSTD;
 	}
 
@@ -1758,7 +1777,8 @@ x_expand(int c)
 	for (i = 0; i < nwords;) {
 		if (x_escape(words[i], strlen(words[i]), x_emacs_putbuf) < 0 ||
 		    (++i < nwords && x_ins(space) < 0)) {
-			x_e_putc(BEL);
+			if (!Flag(FNOBEEP))
+				x_e_putc(BEL);
 			return KSTD;
 		}
 	}
@@ -1782,7 +1802,8 @@ do_complete(int flags,	/* XCF_{COMMAND,F
 	    &start, &end, &words, &is_command);
 	/* no match */
 	if (nwords == 0) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return;
 	}
 
@@ -1947,7 +1968,8 @@ x_set_arg(int c)
 	for (; c >= 0 && isdigit(c); c = x_e_getc(), first = 0)
 		n = n * 10 + (c - '0');
 	if (c < 0 || first) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		x_arg = 1;
 		x_arg_defaulted = 1;
 	} else {
@@ -1969,7 +1991,8 @@ x_comment(int c)
 	int ret = x_do_comment(xbuf, xend - xbuf, &len);
 
 	if (ret < 0)
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 	else {
 		xep = xbuf + len;
 		*xep = '\0';
@@ -2005,7 +2028,8 @@ x_prev_histword(int c)
 
 	cp = *histptr;
 	if (!cp)
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 	else if (x_arg_defaulted) {
 		rcp = &cp[strlen(cp) - 1];
 		/*
@@ -2082,7 +2106,8 @@ x_fold_case(int c)
 	char *cp = xcp;
 
 	if (cp == xep) {
-		x_e_putc(BEL);
+		if (!Flag(FNOBEEP))
+			x_e_putc(BEL);
 		return KSTD;
 	}
 	while (x_arg--) {
Index: misc.c
===================================================================
RCS file: /cvs/src/bin/ksh/misc.c,v
retrieving revision 1.37
diff -p -u -r1.37 misc.c
--- misc.c	19 Apr 2009 20:34:05 -0000	1.37
+++ misc.c	26 Nov 2012 14:25:51 -0000
@@ -140,6 +140,7 @@ const struct option options[] = {
 #else /* JOBS */
 	{ (char *) 0,	'm',		     0 }, /* so FMONITOR not ifdef'd */
 #endif /* JOBS */
+	{ "nobeep",	0,		OF_ANY },
 	{ "noclobber",	'C',		OF_ANY },
 	{ "noexec",	'n',		OF_ANY },
 	{ "noglob",	'f',		OF_ANY },
Index: sh.h
===================================================================
RCS file: /cvs/src/bin/ksh/sh.h,v
retrieving revision 1.31
diff -p -u -r1.31 sh.h
--- sh.h	10 Sep 2012 01:25:30 -0000	1.31
+++ sh.h	26 Nov 2012 14:25:51 -0000
@@ -185,6 +185,7 @@ enum sh_flag {
 	FLOGIN,		/* -l: a login shell */
 	FMARKDIRS,	/* mark dirs with / in file name completion */
 	FMONITOR,	/* -m: job control monitoring */
+	FNOBEEP,	/* don't beep on bell */
 	FNOCLOBBER,	/* -C: don't overwrite existing files */
 	FNOEXEC,	/* -n: don't execute any commands */
 	FNOGLOB,	/* -f: don't do file globbing */
Index: vi.c
===================================================================
RCS file: /cvs/src/bin/ksh/vi.c,v
retrieving revision 1.26
diff -p -u -r1.26 vi.c
--- vi.c	29 Jun 2009 22:50:19 -0000	1.26
+++ vi.c	26 Nov 2012 14:25:51 -0000
@@ -575,7 +575,12 @@ vi_insert(int ch)
 				es->cbuf[es->cursor] = undo->cbuf[es->cursor];
 		} else {
 			if (es->cursor == 0) {
-				/* x_putc(BEL); no annoying bell here */
+				/*
+				 * no annoying bell here
+				 *
+				if (!Flag(FNOBEEP))
+					x_putc(BEL);
+				*/
 				return 0;
 			}
 			if (inslen > 0)
@@ -2105,7 +2110,8 @@ vi_error(void)
 {
 	/* Beem out of any macros as soon as an error occurs */
 	vi_macro_reset();
-	x_putc(BEL);
+	if (!Flag(FNOBEEP))
+		x_putc(BEL);
 	x_flush();
 }
 
Index: ksh.1
===================================================================
RCS file: /cvs/src/bin/ksh/ksh.1,v
retrieving revision 1.144
diff -p -u -r1.144 ksh.1
--- ksh.1	8 Jul 2012 08:13:20 -0000	1.144
+++ ksh.1	26 Nov 2012 19:44:32 -0000
@@ -3705,6 +3704,8 @@ See above for a description of what this
 The shell is a login shell.
 This option can only be used when the shell is invoked.
 See above for a description of what this means.
+.It Ic nobeep
+Do not beep on bell.
 .It Ic nohup
 Do not kill running jobs with a
 .Dv SIGHUP