Skip to content

Commit

Permalink
feat(os_functions): add cmdsep function for command separation Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson-numerical-software committed Jan 3, 2025
1 parent f97cbe3 commit 26bde94
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- [#1322](http://github.com/nelson-lang/nelson/issues/1322) `cmdsep`: Command separator for current operating system.
- `urlencode`: Replace special characters in URLs with escape characters.
- `docroot`: Utility to retrieve or define the root directory of Nelson Help.
- `ismodule`: second input argument `isprotected` added.
Expand Down
4 changes: 3 additions & 1 deletion modules/os_functions/etc/finish.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
% SPDX-License-Identifier: LGPL-3.0-or-later
% LICENCE_BLOCK_END
%=============================================================================
removegateway(modulepath('os_functions', 'builtin'));
rmpath(modulepath('os_functions', 'functions'));
removegateway(modulepath('os_functions', 'builtin'));
%=============================================================================
1 change: 1 addition & 0 deletions modules/os_functions/etc/startup.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
% LICENCE_BLOCK_END
%=============================================================================
addgateway(modulepath('os_functions', 'builtin'), 'os_functions');
addpath(modulepath('os_functions', 'functions'), '-frozen');
%=============================================================================
19 changes: 19 additions & 0 deletions modules/os_functions/functions/cmdsep.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
%=============================================================================
% Copyright (c) 2016-present Allan CORNET (Nelson)
%=============================================================================
% This file is part of the Nelson.
%=============================================================================
% LICENCE_BLOCK_BEGIN
% SPDX-License-Identifier: LGPL-3.0-or-later
% LICENCE_BLOCK_END
%=============================================================================
function varargout = cmdsep(varargin)
nargoutchk(0, 1);
narginchk(0, 0);
if ispc()
varargout{1} = "&&";
else
varargout{1} = ";";
end
end
%=============================================================================
61 changes: 61 additions & 0 deletions modules/os_functions/help/en_US/xml/cmdsep.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xmldoc>
<copyright>SAME AS NELSON SOFTWARE</copyright>

<language>en_US</language>
<keyword>cmdsep</keyword>
<short_description
>Command separator for current operating system.</short_description>

<syntax>
<syntax_item>sep = cmdsep()</syntax_item>
</syntax>

<param_output>

<param_output_item>
<param_name>sep</param_name>
<param_description
>a string: on windows "&amp;&amp;", on linux ";"</param_description>
</param_output_item>
</param_output>


<description>
<p><b
>cmdsep</b> returns the command separator for current operating system.</p>
<p
>This function is used by Nelson to build command lines for unix and dos operating systems.</p>
</description>

<used_function />
<bibliography />

<examples>
<example_item>
<example_item_type>nelson</example_item_type>
<example_item_description />
<example_item_data><![CDATA[unix("cd c:/ " + cmdsep() + " nelson")]]>
</example_item_data>
</example_item>

</examples>

<see_also>
<see_also_item>
<link linkend="${os_functions}unix">unix</link>
</see_also_item>
</see_also>


<history>
<history_item>
<history_version>1.11.0</history_version>
<history_description>initial version</history_description>
</history_item>
</history>

<authors>
<author_item>Allan CORNET</author_item>
</authors>
</xmldoc>
2 changes: 1 addition & 1 deletion modules/os_functions/module.iss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Source: {#RootPath}modules\{#MODULE_NAME}\loader.m; DestDir: {app}\modules\{#MOD
Source: {#RootPath}modules\{#MODULE_NAME}\etc\startup.m; DestDir: {app}\modules\{#MODULE_NAME}\etc\;
Source: {#RootPath}modules\{#MODULE_NAME}\etc\finish.m; DestDir: {app}\modules\{#MODULE_NAME}\etc\;
;==============================================================================
;Source: {#RootPath}modules\{#MODULE_NAME}\functions\*.m; DestDir: {app}\modules\{#MODULE_NAME}\functions\;
Source: {#RootPath}modules\{#MODULE_NAME}\functions\*.m; DestDir: {app}\modules\{#MODULE_NAME}\functions\;
;==============================================================================
Source: {#RootPath}modules\{#MODULE_NAME}\help\*.qch; DestDir: {app}\modules\{#MODULE_NAME}\help\; Flags: recursesubdirs;Components: {#COMPONENT_HELP_FILES} and {#COMPONENT_HELP_BROWSER};
;==============================================================================
Expand Down
15 changes: 15 additions & 0 deletions modules/os_functions/tests/test_cmdsep.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%=============================================================================
% Copyright (c) 2016-present Allan CORNET (Nelson)
%=============================================================================
% This file is part of the Nelson.
%=============================================================================
% LICENCE_BLOCK_BEGIN
% SPDX-License-Identifier: LGPL-3.0-or-later
% LICENCE_BLOCK_END
%=============================================================================
if ispc()
assert_isequal(cmdsep(), "&&");
else
assert_isequal(cmdsep(), ";");
end
%=============================================================================

0 comments on commit 26bde94

Please sign in to comment.