Mercurial > octave
annotate scripts/miscellaneous/dos.m @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 7854d5752dd2 |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
3 ## Copyright (C) 2004-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
5820 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23950
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
5820 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23950
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
5820 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
5820 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
7016 | 21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23950
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
5820 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20515
diff
changeset
|
27 ## @deftypefn {} {} dos ("@var{command}") |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20515
diff
changeset
|
28 ## @deftypefnx {} {@var{status} =} dos ("@var{command}") |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20515
diff
changeset
|
29 ## @deftypefnx {} {[@var{status}, @var{text}] =} dos ("@var{command"}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20515
diff
changeset
|
30 ## @deftypefnx {} {[@dots{}] =} dos ("@var{command}", "-echo") |
19223
eeb2a01cdc26
doc: Improve docstrings for dos() and unix().
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
31 ## Execute a system command if running under a Windows-like operating system, |
eeb2a01cdc26
doc: Improve docstrings for dos() and unix().
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
32 ## otherwise do nothing. |
eeb2a01cdc26
doc: Improve docstrings for dos() and unix().
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
33 ## |
eeb2a01cdc26
doc: Improve docstrings for dos() and unix().
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
34 ## Octave waits for the external command to finish before returning the exit |
eeb2a01cdc26
doc: Improve docstrings for dos() and unix().
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
35 ## status of the program in @var{status} and any output in @var{text}. |
eeb2a01cdc26
doc: Improve docstrings for dos() and unix().
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
36 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
37 ## When called with no output argument, or the @qcode{"-echo"} argument is |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
38 ## given, then @var{text} is also sent to standard output. |
19223
eeb2a01cdc26
doc: Improve docstrings for dos() and unix().
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
39 ## @seealso{unix, system, isunix, ismac, ispc} |
5820 | 40 ## @end deftypefn |
41 | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
42 function [status, text] = dos (command, echo_arg) |
5820 | 43 |
28789
28de41192f3c
Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
44 if (nargin < 1) |
6046 | 45 print_usage (); |
23950
2aa0de22f98a
dos.m, unix.m: Rewrite to always return valid outputs for status and text (bug #51862).
Rik <rik@octave.org>
parents:
23918
diff
changeset
|
46 endif |
2aa0de22f98a
dos.m, unix.m: Rewrite to always return valid outputs for status and text (bug #51862).
Rik <rik@octave.org>
parents:
23918
diff
changeset
|
47 |
2aa0de22f98a
dos.m, unix.m: Rewrite to always return valid outputs for status and text (bug #51862).
Rik <rik@octave.org>
parents:
23918
diff
changeset
|
48 status = 1; |
2aa0de22f98a
dos.m, unix.m: Rewrite to always return valid outputs for status and text (bug #51862).
Rik <rik@octave.org>
parents:
23918
diff
changeset
|
49 text = ""; |
2aa0de22f98a
dos.m, unix.m: Rewrite to always return valid outputs for status and text (bug #51862).
Rik <rik@octave.org>
parents:
23918
diff
changeset
|
50 |
2aa0de22f98a
dos.m, unix.m: Rewrite to always return valid outputs for status and text (bug #51862).
Rik <rik@octave.org>
parents:
23918
diff
changeset
|
51 ## FIXME: Should this be ispc ()? There may be an issue with MinGW |
2aa0de22f98a
dos.m, unix.m: Rewrite to always return valid outputs for status and text (bug #51862).
Rik <rik@octave.org>
parents:
23918
diff
changeset
|
52 if (! isunix ()) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
53 [status, text] = system (command); |
5820 | 54 if (nargin > 1 || nargout == 0) |
21634
96518f623c91
Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents:
21633
diff
changeset
|
55 printf ("%s\n", text); |
5820 | 56 endif |
57 endif | |
58 | |
59 endfunction | |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
60 |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
61 |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
62 %!test |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
63 %! cmd = ls_command (); |
20515
76f67400649e
Use '-local' option to warning to simplify BIST tests.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
64 %! [status, output] = dos (cmd); |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
65 %! |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
66 %! if (ispc () && ! isunix ()) |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
67 %! [status, output] = dos (cmd); |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
68 %! assert (status, 0); |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
69 %! assert (ischar (output)); |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
70 %! assert (! isempty (output)); |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
71 %! else |
23950
2aa0de22f98a
dos.m, unix.m: Rewrite to always return valid outputs for status and text (bug #51862).
Rik <rik@octave.org>
parents:
23918
diff
changeset
|
72 %! assert (status, 1); |
2aa0de22f98a
dos.m, unix.m: Rewrite to always return valid outputs for status and text (bug #51862).
Rik <rik@octave.org>
parents:
23918
diff
changeset
|
73 %! assert (output, ""); |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
74 %! endif |
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
75 |
28896
90fea9cc9caa
test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents:
28789
diff
changeset
|
76 ## Test input validation |
90fea9cc9caa
test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents:
28789
diff
changeset
|
77 %!error <Invalid call> dos () |
14018
5d5685216876
Deprecate shell_cmd function and update system, dos, unix commands
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
78 %!error dos (1, 2, 3) |