diff options
| author | Ron Yorston <rmy@pobox.com> | 2024-04-09 08:58:58 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2024-04-09 08:58:58 +0100 |
| commit | fcf3ec2877f042c6957d808e562807089e23ebe6 (patch) | |
| tree | 02fc4bf8d6fd8284564d3cf27cbd17482b8f5744 /shell | |
| parent | 55ecf3a746db5131ca078875168a59feab8b26f1 (diff) | |
| download | busybox-w32-fcf3ec2877f042c6957d808e562807089e23ebe6.tar.gz busybox-w32-fcf3ec2877f042c6957d808e562807089e23ebe6.tar.bz2 busybox-w32-fcf3ec2877f042c6957d808e562807089e23ebe6.zip | |
ash: add title built-in
Implement a 'title' built-in for ash. It's very simple-minded,
performs almost no error checking and is completely non-portable.
- With no arguments it prints the current console title.
- If arguments are provided the *first only* is set as the console
title.
Costs 88-116 bytes.
(GitHub issue #401)
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/ash.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c index d312cb8cd..df27e9c8d 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
| @@ -11253,6 +11253,9 @@ static int readcmd(int, char **) FAST_FUNC; | |||
| 11253 | static int setcmd(int, char **) FAST_FUNC; | 11253 | static int setcmd(int, char **) FAST_FUNC; |
| 11254 | static int shiftcmd(int, char **) FAST_FUNC; | 11254 | static int shiftcmd(int, char **) FAST_FUNC; |
| 11255 | static int timescmd(int, char **) FAST_FUNC; | 11255 | static int timescmd(int, char **) FAST_FUNC; |
| 11256 | #if ENABLE_PLATFORM_MINGW32 | ||
| 11257 | static int titlecmd(int, char **) FAST_FUNC; | ||
| 11258 | #endif | ||
| 11256 | static int trapcmd(int, char **) FAST_FUNC; | 11259 | static int trapcmd(int, char **) FAST_FUNC; |
| 11257 | static int umaskcmd(int, char **) FAST_FUNC; | 11260 | static int umaskcmd(int, char **) FAST_FUNC; |
| 11258 | static int unsetcmd(int, char **) FAST_FUNC; | 11261 | static int unsetcmd(int, char **) FAST_FUNC; |
| @@ -11352,6 +11355,9 @@ static const struct builtincmd builtintab[] = { | |||
| 11352 | { BUILTIN_REGULAR "test" , testcmd }, | 11355 | { BUILTIN_REGULAR "test" , testcmd }, |
| 11353 | #endif | 11356 | #endif |
| 11354 | { BUILTIN_SPEC_REG "times" , timescmd }, | 11357 | { BUILTIN_SPEC_REG "times" , timescmd }, |
| 11358 | #if ENABLE_PLATFORM_MINGW32 | ||
| 11359 | { BUILTIN_REGULAR "title" , titlecmd }, | ||
| 11360 | #endif | ||
| 11355 | { BUILTIN_SPEC_REG "trap" , trapcmd }, | 11361 | { BUILTIN_SPEC_REG "trap" , trapcmd }, |
| 11356 | { BUILTIN_REGULAR "true" , truecmd }, | 11362 | { BUILTIN_REGULAR "true" , truecmd }, |
| 11357 | { BUILTIN_REGULAR "type" , typecmd }, | 11363 | { BUILTIN_REGULAR "type" , typecmd }, |
| @@ -15549,6 +15555,21 @@ timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
| 15549 | return 0; | 15555 | return 0; |
| 15550 | } | 15556 | } |
| 15551 | 15557 | ||
| 15558 | #if ENABLE_PLATFORM_MINGW32 | ||
| 15559 | static int FAST_FUNC | ||
| 15560 | titlecmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | ||
| 15561 | { | ||
| 15562 | if (*argptr == NULL) { | ||
| 15563 | char buffer[256]; | ||
| 15564 | if (get_title(buffer, sizeof(buffer))) | ||
| 15565 | puts(buffer); | ||
| 15566 | } else { | ||
| 15567 | set_title(*argptr); | ||
| 15568 | } | ||
| 15569 | return 0; | ||
| 15570 | } | ||
| 15571 | #endif | ||
| 15572 | |||
| 15552 | #if ENABLE_FEATURE_SH_MATH | 15573 | #if ENABLE_FEATURE_SH_MATH |
| 15553 | /* | 15574 | /* |
| 15554 | * The let builtin. Partially stolen from GNU Bash, the Bourne Again SHell. | 15575 | * The let builtin. Partially stolen from GNU Bash, the Bourne Again SHell. |
