← Commit list

fd5fb2d2b

Denys Vlasenko
Denys Vlasenko
2023-04-01
SUCCESS Duration: 158s

Subject

hush: speed up "big heredoc" code

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/hush.c+15 -7
@@ -10260,6 +10260,20 @@ int hush_main(int argc, char **argv)
INIT_G();
if (EXIT_SUCCESS != 0) /* if EXIT_SUCCESS == 0, it is already done */
G.last_exitcode = EXIT_SUCCESS;
+#if !BB_MMU
+ /* "Big heredoc" support via "sh -< STRING" invocation.
+ * Check it first (do not bother to run the usual init code,
+ * it is not needed for this case).
+ */
+ if (argv[1]
+ && argv[1][0] == '-' && argv[1][1] == '<' /*&& !argv[1][2]*/
+ /*&& argv[2] && !argv[3] - we don't check some conditions */
+ ) {
+ full_write1_str(argv[2]);
+ _exit(0);
+ }
+ G.argv0_for_re_execing = argv[0];
+#endif
#if ENABLE_HUSH_TRAP
# if ENABLE_HUSH_FUNCTIONS
G.return_exitcode = -1;
@@ -10270,9 +10284,6 @@ int hush_main(int argc, char **argv)
#if ENABLE_HUSH_FAST
G.count_SIGCHLD++; /* ensure it is != G.handled_SIGCHLD */
#endif
-#if !BB_MMU
- G.argv0_for_re_execing = argv[0];
-#endif
cached_getpid = getpid(); /* for tcsetpgrp() during init */
G.root_pid = cached_getpid; /* for $PID (NOMMU can override via -$HEXPID:HEXPPID:...) */
@@ -10388,7 +10399,7 @@ int hush_main(int argc, char **argv)
int opt = getopt(argc, argv, "+" /* stop at 1st non-option */
"cexinsl"
#if !BB_MMU
- "<:$:R:V:"
+ "$:R:V:"
# if ENABLE_HUSH_FUNCTIONS
"F:"
# endif
@@ -10438,9 +10449,6 @@ int hush_main(int argc, char **argv)
flags |= OPT_login;
break;
#if !BB_MMU
- case '<': /* "big heredoc" support */
- full_write1_str(optarg);
- _exit(0);
case '$': {
unsigned long long empty_trap_mask;