Mercurial > octave
changeset 26183:341d927513dd
avoid unnecessary use of global variable
* ls_command.m (__ls_comand__): Declare persistent instead of global.
* ls.m: Simply call ls_command instead of accessing global
__ls_command__ variable.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 07 Dec 2018 17:29:30 -0500 |
parents | 34617dd78f02 |
children | 572329faeb3b |
files | scripts/miscellaneous/ls.m scripts/miscellaneous/ls_command.m |
diffstat | 2 files changed, 2 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/ls.m Fri Dec 07 17:30:31 2018 -0500 +++ b/scripts/miscellaneous/ls.m Fri Dec 07 17:29:30 2018 -0500 @@ -55,12 +55,6 @@ function retval = ls (varargin) - global __ls_command__; - - if (isempty (__ls_command__) || ! ischar (__ls_command__)) - ls_command (); # Initialize global value for __ls_command__. - endif - if (! iscellstr (varargin)) error ("ls: all arguments must be character strings"); endif @@ -90,7 +84,7 @@ args = ["-1 ", args]; endif - cmd = [__ls_command__ " " args]; + cmd = [ls_command() " " args]; if (page_screen_output () || nargout > 0) [status, output] = system (cmd);
--- a/scripts/miscellaneous/ls_command.m Fri Dec 07 17:30:31 2018 -0500 +++ b/scripts/miscellaneous/ls_command.m Fri Dec 07 17:29:30 2018 -0500 @@ -27,7 +27,7 @@ function old_val = ls_command (new_val) - global __ls_command__; + persistent __ls_command__; if (isempty (__ls_command__)) ## MinGW uses different ls_command