[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] Add a 'busybox --list name' option to display script content
From:       Walter Harms <wharms () bfs ! de>
Date:       2018-11-25 15:13:36
Message-ID: 440665848.58903.1543158816538 () ox-groupware ! bfs ! de
[Download RAW message or body]


Am 09.11.2018 19:10, schrieb Ron Yorston:
> Add an option to allow the content of embedded scripts to be
> displayed.
> 


> @@ -865,6 +877,22 @@ int busybox_main(int argc UNUSED_PARAM, char **argv)
>  #  else
>  		const char *a = applet_names;
>  #  endif
> +
> +		if (LIST_CONTENT && argv[1][6] == '\0' && argv[2] != NULL) {
> +			int n = (HAS_PROFILE && strcmp(argv[2], ".profile") == 0) ? 0 :
> +						find_script_by_name(argv[2]);
> +			if (n >= 0) {
> +				char *script = get_script_content(n);
> +				if (script != NULL) {
> +					full_write1_str(script);
> +				}
> +			}
> +			else {
> +				bb_error_msg_and_die("script '%s' not found", argv[2]);
> +			}
> +			return 0;
> +		}
> +

i would write that a bit different to improve readability:
 
                        char *script;
                        int n = (HAS_PROFILE && strcmp(argv[2], ".profile") ==
0) ? 0 :
 			                  find_script_by_name(argv[2]);

                        if ( n<0 )
                          bb_error_msg_and_die("script '%s' not found",
argv[2]);
		 
		        script = get_script_content(n);
			if (script != NULL) 
   			       full_write1_str(script);			
		        return 0;
	    }


just my 2 cents,
re,
 wh
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic