aboutsummaryrefslogtreecommitdiff
path: root/miscutils (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* | iconv: fix incorrect fixRon Yorston2023-11-081-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | Part of commit 412c2cab62 (iconv: minor fixes) was intended to avoid having to enter ^Z twice to signal EOF when input was coming from the console. Unfortunately there were unintended consequences. Use a different method to detect EOF. Costs 32-48 bytes. (GitHuv issue #374)
* | make: stricter checks for c:/path filenamesRon Yorston2023-10-241-6/+9
| | | | | | | | | | | | | | | | | | | | When checking target names or looking for a target rule be more strict about the form of Windows paths allowed. Alter the error message when neither a target rule or macro assignment has been detected. Adds 88-96 bytes.
* | make: fix detection of target rulesRon Yorston2023-10-231-152/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The presence of an equal sign in an inline command on a target rule caused the line to be detected as a macro assignment. For example: target:; @echo a = $(a) Rearrange input parsing so target rules are detected before macro assignments. This is made more complex by having to allow for the ':=', '::=' and ':::=' assignment operators. (And for targets containing colons on Windows.) Costs 240-248 bytes.
* | make: permit Unix-style paths when setting MAKERon Yorston2023-10-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'make' applet follows POSIX requirements when setting the MAKE variable. However, it doesn't allow for the case where argv[0] is of a form like '/bin/make' but no corresponding executable exists. This can happen in busybox-w32 when '/bin/make' is interpreted as a reference to the 'make' applet. In this case set the MAKE variable to argv[0] and avoid issuing a warning. Setting MAKE to something that isn't a real executable is fine so long as it's only used by busybox-w32 applets. If it's used by external applications they may get confused. Adds 16-32 bytes. (GitHub issue #354)
* | win32: convert exit codesRon Yorston2023-09-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add two utility functions to convert Windows process exit codes. - exit_code_to_wait_status() converts to a POSIX wait status. This is used in ash and the implementations of system(3) and mingw_wait3(). - exit_code_to_posix() converts to a POSIX exit code. (Not that POSIX has much to say about them.) As a result it's possible for more applets to report when child processes are killed as if by a signal. 'time', 'drop' and 'su -W', for example. Adds 64-80 bytes.
* | make: return non-zero exit status when a command failsRon Yorston2023-09-121-10/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a build command returned a non-zero exit status 'make' reported a warning and returned an exit code of zero. This was due to the misuse of the status returned by system(3). As the man page says: the return value is a "wait status" that can be examined using the macros described in waitpid(2). (i.e., WIFEXITED(), WEXITSTATUS(), and so on). Use the error() function to correctly report the problem on stderr and return an exit status of 2. Some additional changes in the same area: - When a target is removed report the diagnostic on stderr, as required by POSIX. - When a build command receives a signal GNU make removes the target. bmake doesn't and it isn't required by POSIX. Implement this as an extension. - Expand the error message when a build command fails so it includes the exit status or signal number, as obtained from the value returned by system(3). - Alter the WIN32 implementation of system(3) to handle exit codes which represent termination as if by a signal. Adds 200-240 bytes. (GitHub issue #354)
* | make: avoid more warningsRon Yorston2023-09-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tracking of progress introduced in commit fb4be267c (make: fixes to warning messages) failed to account for runs with the '-t' or '-n' options. Without this the following makefile: dummy_target: dummy_rule dummy_rule: @: issues the warning 'make: nothing to be done for dummy_target' when run with '-t' or '-n' and no 'dummy_rule' file present. (GitHub issue #354)
* | make: fixes to warning messagesRon Yorston2023-08-251-28/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to POSIX only fatal diagnostic messages should be written to stderr. Arrange for warning() to write to stdout. pdpmake was rather too prolific in generating 'nothing to be done for XXX' messages. GNU make only issues the equivalent message for top-level targets and only if nothing at all was (or would have been) done. bmake doesn't seem to have such a message. Follow the practice of GNU make. This requires more intensive tracking of the actions taken while the make is in progress. Costs 16 bytes. (GitHub issue #354)
* | make: fix .DEFAULT for prerequisiteRon Yorston2023-08-241-1/+0
| | | | | | | | | | | | | | | | | | | | Commit 4b65e7d9 (Fixes to inference rules) set the N_TARGET flag for prerequisites being built recursively. That wasn't necessary for the issue at hand and it lead to other problems. Undo that part of commit 4b65e7d9. (GitHub issue #354)
* | make: fix POSIX buildRon Yorston2023-08-241-0/+15
| | | | | | | | | | | | | | | | If upstream BusyBox had a 'make' applet a native build with it enabled should match the corresponding build from the busybox-w32 source. Make it so.
* | make: allow targets of the form c:/pathRon Yorston2023-08-231-2/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Parsing of target rules was too simplistic to allow targets of the form c:/path. Allow such targets as a non-POSIX extension. Also add a 'windows' pragma to allow such targets in POSIX mode. This additionally requires the use of the 'target_name' pragma to permit slashes in target names. This change *doesn't* allow targets of the form c:path, but it's probably not wise to use them anyway. Costs 40-80 bytes. (GitHub issue #353)
* | Merge branch 'busybox' into mergeRon Yorston2023-08-104-3/+140
|\|
| * introduce and use exitcode_tDenys Vlasenko2023-07-174-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta strings_main 422 420 -2 setfattr_main 175 173 -2 brctl_main 1548 1546 -2 makedevs_main 979 975 -4 rev_main 337 332 -5 getfattr_main 307 302 -5 cut_main 1201 1196 -5 cksum_main 398 393 -5 umount_main 573 565 -8 ln_main 516 508 -8 expand_main 660 652 -8 df_main 1068 1060 -8 renice_main 346 332 -14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/13 up/down: 0/-76) Total: -76 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * getfattr: fix "getfattr NOTEXIST" - now prints error msgDenys Vlasenko2023-07-171-4/+9
| | | | | | | | | | | | | | | | | | | | function old new delta getfattr_main 309 307 -2 .rodata 105395 105391 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6) Total: -6 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * getfattr: new appletYU Jincheng2023-07-161-0/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta getfattr_main - 309 +309 print_attr - 115 +115 packed_usage 34576 34631 +55 .rodata 105349 105395 +46 lgetxattr - 41 +41 getxattr - 41 +41 llistxattr - 35 +35 listxattr - 35 +35 applet_names 2806 2815 +9 applet_main 1620 1624 +4 ------------------------------------------------------------------------------ (add/remove: 7/0 grow/shrink: 4/0 up/down: 690/0) Total: 690 bytes Signed-off-by: YU Jincheng <shana@zju.edu.cn> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2023-07-1332-47/+47
|\|
| * i2ctransfer: fix build warningDenys Vlasenko2023-07-101-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Update applet size estimatesDenys Vlasenko2023-07-1031-42/+42
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: code shrink: introduce and use [_]exit_FAILURE()Denys Vlasenko2023-06-152-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta exit_FAILURE - 7 +7 _exit_FAILURE - 7 +7 run 198 199 +1 restore_state_and_exit 114 115 +1 xbsd_write_bootstrap 399 397 -2 vfork_compressor 209 207 -2 sig_handler 12 10 -2 serial_ctl 154 152 -2 parse_args 1169 1167 -2 onintr 21 19 -2 make_new_session 493 491 -2 login_main 988 986 -2 gotsig 35 33 -2 do_iplink 1315 1313 -2 addgroup_main 397 395 -2 inetd_main 1911 1908 -3 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 2/12 up/down: 16/-25) Total: -9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | make: code shrinkRon Yorston2023-06-081-1/+1
| | | | | | | | Saves 8 bytes in the 32-bit build.
* | win32: remove special treatment of USERNAMERon Yorston2023-06-051-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit 255ebaf535 (drop: adjust environment on privilege change) added USERNAME to the variables subject to special treatment when the shell starts or privilege is dropped. It's been pointed out this may not be appropriate for a variable that's Windows-specific. Remove the special treatment of USERNAME. Saves 40-48 bytes. (GitHub issue #300)
* | drop: changes to ctrl-c handlingRon Yorston2023-05-231-12/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the new kill_child_ctrl_handler() function: - Ctrl-C can be used to terminate non-console applications. - Ctrl-C in an interactive cmd.exe or PowerShell session won't cause drop to terminate. Also: - Use getopt32() to process options. - Update usage messages. Adds 96-160 bytes.
* | make: special treatment of archive membersRon Yorston2023-05-011-4/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The standard says: If a target or prerequisite contains parentheses, it shall be treated as a member of an archive library. For the lib(member.o) expression lib refers to the name of the archive library and member.o to the member name. 'lib(member.o)' is referred to as an 'expression' rather than a name; 'lib' and 'member.o' are called names. Allow for this in is_valid_name() by splitting such expressions into separate archive/member names and checking these individually.
* | iconv: use temporary file for outputRon Yorston2023-04-271-2/+11
| | | | | | | | | | | | | | | | On Linux iconv allows the output file specified with '-o' to be the same as the input file. Do the same for our version by creating a temporary output file and renaming it on completion. Costs 64-88 bytes.
* | win32: export xappendword()Ron Yorston2023-04-232-16/+1
| | | | | | | | | | | | | | Export the function xappendword() from make. Use it in drop and watch. Saves 8-80 bytes, an unusually large disparity.
* | Merge branch 'busybox' into mergeRon Yorston2023-04-171-2/+22
|\|
| * seedrng: fix for glibc <= 2.24 not providing random headerThomas Devoogdt2023-04-111-4/+10
| | | | | | | | | | | | | | | | | | | | - dropped the wrong define (not sure why it was there) - <sys/random.h> not available if glibc <= 2.24 - GRND_NONBLOCK not defined if <sys/random.h> not included - ret < 0 && errno == ENOSYS has to be true to get creditable set Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * seedrng: fix for glibc <= 2.24 not providing getrandom()Denys Vlasenko2023-04-101-0/+14
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Remove "select PLATFORM_LINUX"Denys Vlasenko2022-11-295-9/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Fix non-Linux buildsSamuel Thibault2022-11-295-0/+9
| | | | | | | | | | | | | | | | | | | | | | Various tools are Linuxish and should thus only attempted to build on Linux only. Some features are also Linux-only. Also, libresolv is used on all GNU platforms, notably GNU/Hurd and GNU/kfreeBSD. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | drop: adjust environment on privilege changeRon Yorston2023-03-271-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some environment variables are subject to special treatment: USER, LOGNAME, HOME and SHELL are initialised when the shell starts if they don't already have a value. Some adjustments are necessary when changing privilege level: - USERNAME is added to the set of variables subject to special treatment. Unlike the others this is normally set on Windows. - The special variables are now also updated on shell start up if the current process is running with elevated privileges. This is necessary so USER, USERNAME and LOGNAME have the correct value. - USER, USERNAME and LOGNAME are set to the name of the unprivileged user when elevated privileges are dropped, though not if they've been changed from the expected value of "root". Costs 160-208 bytes. (GitHub issue #300)
* | drop: cdrop and pdrop don't need shellRon Yorston2023-03-231-8/+18
| | | | | | | | | | | | | | | | | | The cdrop and pdrop variants don't require the binary to include a shell. Removing this dependency makes it possible to build cdrop/pdrop as a much smaller standalone binaries. Update the default configuration to build a standalone make binary to exclude drop/cdrop/pdrop.
* | drop: search PATH for cmd.exe/PowerShellRon Yorston2023-03-231-27/+25
| | | | | | | | | | | | | | | | | | Rather than hardcode the paths of cmd.exe and PowerShell find them by searching PATH. Saves 104-128 bytes. (GitHub issue #240)
* | drop: add cdrop and pdrop aliasesRon Yorston2023-03-191-3/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add cdrop and pdrop applets as aliases for drop. If a command isn't specified these use cmd.exe and PowerShell instead of the BusyBox shell. This makes it possible to choose the default shell used for SSH connections even in older versions of OpenSSH that don't support the DefaultShellArguments registry key. Note that to get cmd.exe to run a command rather than an interactive shell it's necessary to set the DefaultShellCommandOption registry key to '/c'. Costs 248-272 bytes.
* | runuser,drop: drop runuser, tweak dropRon Yorston2023-03-191-0/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the runuser applet, leaving only drop. Move drop from util-linux to miscutils. A command of the form 'drop -c command' causes the BusyBox shell to be used, just like 'drop' without any arguments. A simple OpenSSH configuration with 'drop.exe' as DefaultShell and no DefaultShellArguments now works both for interactive login and to run a command. This is useful for older versions of OpenSSH which don't support DefaultShellArguments. Saves 208-232 bytes.
* | make: code shrinkRon Yorston2023-03-161-2/+2
| | | | | | | | | | | | Use alloc_ext_space() instead of a hand-coded equivalent. Saves 16-32 bytes.
* | win32: add support for virtual terminal inputRon Yorston2023-03-051-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Alter certain applets to support virtual terminal input, if enabled. In many places this is achieved by building previously excluded upstream terminal-handling code. The busybox-w32 implementation of termios(3) functions does nothing if virtual terminal input is disabled, so it can be invoked regardless. Some applet-specific terminal-handling code is also required. This affects less, more, vi and command line editing in the shell. (The `more` applet isn't enabled in the default configuration.) This series of patches adds about 1.7KB to the binaries.
* | make: strip leading whitespace in shell assignmentRon Yorston2023-02-011-11/+28
| | | | | | | | | | | | | | | | | | | | | | | | Assignment of shell output to a macro ('!=') was originally a non-POSIX extension. It later became a POSIX 202X feature. However, the implementation failed to include the additional POSIX requirement that leading whitespace is removed from the shell output. Neither GNU make nor bmake strip leading whitespace. Implement this behaviour as a non-POSIX extension.
* | make: allow building as pdpmake onlyRon Yorston2023-01-241-0/+1
| | | | | | | | | | | | | | | | | | Commit f261d2d27 (make: make + sh configuration) added 'pdpmake' as an alias for 'make'. It should have been possible to include 'pdpmake' in a build without also including 'make'. Adjust the build configuration so this works as intended.
* | make: add '-x' option to set pragmasRon Yorston2022-11-211-50/+92
| | | | | | | | | | | | Add a command line option to allow pragmas to be set. This is an alternative to the use of the .PRAGMA special target. The same pragmas are supported.
* | make: add .PRAGMA special targetRon Yorston2022-11-181-38/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the special target .PRAGMA. This allows certain features of the POSIX standard to be disabled when POSIX mode is being enforced. This is done by setting prerequisites of .PRAGMA, as follows: - macro names containing '-' are permitted with the 'macro_name' prerequisite; - target names containing '-' or '/' are permitted with the 'target_name' prerequisite; - the '#' character isn't treated as the start of a comment in a command line with the 'command_comment' prerequisite; - an empty suffix is permitted in a macro expansion of the form $(VAR:=.c) with the 'empty_suffix' prerequisite. Additionally the 'posix_202x' prerequisite enforces the future POSIX standard instead of the current one. In this case the 'macro_name' and 'target_name' pragmas aren't required as the future standard will allow the additional characters. .PRAGMA without any prerequisites restores the default behaviour.
* | make: changes to suffix substitution in macro expansionRon Yorston2022-11-161-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The POSIX standard defines suffix substitution in macro expansion as taking the form: $(string1 [: subst1 =[ subst2 ]]) Since 'subst1' isn't bracketed a value must be supplied. Enforce this in POSIX mode. As a non-POSIX extension an empty 'subst1' is permitted with 'subst2' being added to all words unconditionally. If both 'subst1' and 'subst2' are empty the words are returned unchanged.
* | make: show location of errors during buildRon Yorston2022-11-161-15/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Error messages only displayed the location of an error while the makefile was being parsed. Store the location (makefile name and line number) of each command line. This allows location information to be displayed in errors encountered while targets are being built. Take this Makefile, for example: target: @echo $(hello Previously this would display: make: unterminated variable '$(hello' Now it shows: make: (Makefile:2): unterminated variable '$(hello'
* | make: fix typo in help textRon Yorston2022-11-141-2/+2
| |
* | make: use correct test for valid macro nameRon Yorston2022-11-131-1/+1
| | | | | | | | | | The test for valid macro names in POSIX mode was incorrect: it shouldn't have allowed '-'.
* | make: make + sh configurationRon Yorston2022-11-101-1/+8
| | | | | | | | | | | | Add a configuration that just includes make and a shell. Add 'pdpmake' as an alias for 'make'.
* | make: fix typo in inference rule handlingRon Yorston2022-11-041-1/+1
| | | | | | | | | | | | | | A typo in the previous commit caused dyndep() to process inference rules incorrectly. This didn't affect the results of the test suite when extensions were allowed but it caused the test 'Inference rule with explicit rule for prerequisite' to fail in POSIX mode.
* | make: fixes to inference rulesRon Yorston2022-11-031-18/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Austin Group defect report 875 clarifies some aspects of inference rules. The crux of the issue is related to chained inference rules so it doesn't affect POSIX mode. The test makefile looks like this: .SUFFIXES: .a .b .c .a.c: @echo .a.c .b.c: @echo .b.c test.c: test.b test.a: test.b: The correct output is deemed to be '.a.c'. Additional complications are: - whether or not the prerequisite files are present; - the use of the suffixes '.a' and '.c' may result in the builtin inference rule '.c.a' being considered. In favourable circumstances pdpmake managed to give the correct result, in unfavourable it reported circular dependencies or segfaulted. Changes to fix these issues are: - When prerequisites are being recursively built the standard says: 'Upon recursion, each prerequisite shall become a target itself.' Follow this requirement. - At the end of make() the target being built should have its time (as represented by n_tim in struct name) updated when any action has been taken. - When dyndep() is looking for prerequisites it should: * skip candidates that are in the process of being built; * consider whether an explicit candidate is a target, not whether it has any commands associated with it. pdpmake now behaves similarly to GNU make when presented with makefiles like the above. bmake gives the incorrect output '.b.c'.
* | make: comments in macro expansions and command linesRon Yorston2022-11-011-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The POSIX specification says: There are three kinds of comments: blank lines, empty lines, and a <number-sign> ('#') and all following characters up to the first unescaped <newline> character. Most implementations don't treat '#' in a macro expansion or a command line as the start of a comment. POSIX doesn't mention either of these exceptions. Permit the exceptions as a non-POSIX extension.
* | make: different treatment for escaped NL in macro in commandRon Yorston2022-10-301-6/+24
| | | | | | | | | | | | | | Austin Group defect report 1549 has been accepted. It requires that an escaped newline inside a macro expansion in a command is replaced by a space. Other escaped newlines in commands are left in place, as before.