Re: [PATCH] ash: make bash_source command search current directory after PATH

2018-01-27 Thread Kang-Che Sung
2018年1月28日 上午5:05,"Paul Otto" 寫道:

Thanks for taking care of this, Denys. It didn't wind up the way I'd hoped,
but at least it is predictable both ways now. I will see if there is a way
to get Alpine Linux to build with that config option set, to resolve the
regression introduced by busybox 1.27.


I wonder when people suggest adding a config option to make "source"/"."
command bash-compatible, why aren't they bothered to append the "."
directory at the end of $PATH and save the bloat on the shell code.

Also, I suggest the new BASH_SOURCE_CURDIR be _one_ config option across
both shells, instead of allowing different behaviors of two shells in one
binary. And since this is about behavior change and not a feature
"extension", I think we have no need for this config option to depend on
*_BASH_COMPAT.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] ash: make bash_source command search current directory after PATH

2018-01-27 Thread Paul Otto
Thanks for taking care of this, Denys. It didn't wind up the way I'd hoped,
but at least it is predictable both ways now. I will see if there is a way
to get Alpine Linux to build with that config option set, to resolve the
regression introduced by busybox 1.27.

- Paul
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: adding lineno implementation

2018-01-27 Thread Denys Vlasenko
On Wed, Jan 24, 2018 at 9:53 AM, daggs  wrote:
>> >> Implemented in git a bit differently
>> >>
>> >
>> > not sure I follow, is there an existing implementation for busybox?
>>
>> I applied an implementation to busybox git, please "git pull" and take a 
>> look.
>
> I see, you've committed support for lineno for ash, I'm using hush for bash 
> emulation

BTW, I would like to know where hush finds its uses.
What are you using it for (what project)?
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 0/4] Add SCHED_BATCH and SCHED_IDLE support to chrt

2018-01-27 Thread Denys Vlasenko
On Wed, Jan 24, 2018 at 1:28 AM, Povilas Kanapickas  wrote:
>>> The following patches add SCHED_BATCH and SCHED_IDLE support to chrt.
>>> The priority limits are fixed to follow the specification. The last
>>> patch avoids hardcoding the values of SCHED_* macros as array indices.
>>> Perhaps counter-intuitively, this leads to binary size reduction of
>>> 90 bytes on x86-64. However the patch series as a whole still increase
>>> the binary size by 173 bytes on x86-64.
>>
>> Applied patches 1 and 2. Fixed a problem of patch 3 a bit differently.
>> Patch 4 increases the code, not applied.
>
> Thanks a lot.
>
> I'd like to know what I missed with regards to code size increase. Which
> architectures do you check the code size on? Is there anything else I
> should've known? Maybe the size of the text segment carries more weight
> than e.g. rodata or something similar?

This may depend on toolchain and libc. In my test, with my toolchain,
it was not a win.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] ash: make bash_source command search current directory after PATH

2018-01-27 Thread Denys Vlasenko
I already committed a similar patch to git.

On Fri, Jan 26, 2018 at 5:46 PM, Paul Otto  wrote:
> I have modified this patch per your review comments. For what it's worth, I
> went through hush, and found that it still exhibits the BASH non-POSIXy
> behavior. Take a look:
>
> static char *find_in_path(const char *arg)
> {
> ...
> if (sz != 0) {
> ret = xasprintf("%.*s/%s", sz, PATH, arg);
> } else {
> /* We have xxx:: in $PATH,
> * it means "use current dir" */
> ret = xstrdup(arg);
> }
> if (access(ret, F_OK) == 0)
> break;
> ...
>
> 
>
> static int FAST_FUNC builtin_source(char **argv)
> {
> ...
> if (!strchr(filename, '/')) {
> arg_path = find_in_path(filename);
> if (arg_path)
> filename = arg_path;
> }
> ...
>
> 
>
>  shell/ash.c | 26 --
>  1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git i/shell/ash.c w/shell/ash.c
> index 865159d20..c9edce16c 100644
> --- i/shell/ash.c
> +++ w/shell/ash.c
> @@ -60,6 +60,20 @@
>  //config:  from GNU bash, which allows for alternative command not
> found
>  //config:  handling.
>  //config:
> +//config:config ASH_BASH_NON_POSIX_DOTCMD
> +//config:  bool "non-POSIXy dotcmd behavior (ie: .  or source
> )"
> +//config:  default n
> +//config:  depends ASH_BASH_COMPAT
> +//config:  help
> +//config:  Activates the expected, non-POSIXy behavior BASH follows
> when
> +//config:  dotcmd is invoked with either ". " or "source ".
> In
> +//config:  BASH, when the dotcmd is combined with a filename without an
> +//config:  absolute or relative path specified, the shell first scans
> the
> +//config:  environment's PATH, followed by the present working
> directory
> +//config:  (PWD). The POSIX-compliant command does NOT scan the present
> +//config:  working directory. This option is disabled by default for
> improved
> +//config:  speed and security.
> +//config:
>  //config:config ASH_JOB_CONTROL
>  //config:  bool "Job control"
>  //config:  default y
> @@ -12967,7 +12981,10 @@ find_dot_file(char *name)
> if (strchr(name, '/'))
> return name;
>
> -   while ((fullname = path_advance(, name)) != NULL) {
> +while ((fullname = path_advance(, name)) != NULL) {
> +#if ASH_BASH_NON_POSIX_DOTCMD
> +try_cur_dir:
> +#endif
> if ((stat(fullname, ) == 0) && S_ISREG(statb.st_mode))
> {
> /*
>  * Don't bother freeing here, since it will
> @@ -12980,7 +12997,12 @@ find_dot_file(char *name)
> }
>
> /* not found in the PATH */
> -   ash_msg_and_raise_error("%s: not found", name);
> +#if ASH_BASH_NON_POSIX_DOTCMD
> +fullname = name;
> +goto try_cur_dir;

you can simply "return name" here.

> +#endif
> +/* not found at all */
> +ash_msg_and_raise_error("%s: not found", name);
> /* NOTREACHED */
>  }
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox