#1103896 octave: unlink raises an error on failure, but his is undocumented

Package:
octave
Source:
octave
Description:
GNU Octave language for numerical computations
Submitter:
Francesco Potortì
Date:
2025-04-22 19:42:03 UTC
Severity:
normal
Tags:
#1103896#5
Date:
2025-04-22 15:14:26 UTC
From:
To:
octave> unlink nonexistent_file
error: unlink: operation failed: No such file or directory

An old script of mine fails because of this.  Once upon a time Octave did not raise an error upno failure of unlink.  This should be documented

#1103896#10
Date:
2025-04-22 15:43:19 UTC
From:
To:
* Francesco Potortì <Potorti@isti.cnr.it> [2025-04-22 17:14]:

The behavior of unlink and many other functions has been changed in
version 7.0 of Octave. This is well documented. Here is an excerpt of
the file etc/NEWS.7.md:

[https://hg.octave.org/octave/file/tip/etc/NEWS.7.md]

==========================================================================

  ### General improvements

  - Many functions in Octave can be called in a command form---no
  parentheses for invocation and no return argument assignment---or in a
  functional form---parentheses and '=' for assignment of return values.

     **Command Form Example**

     `mkdir new_directory`

     **Function Form Example**

     `status = mkdir ("new_directory")`

     Octave now handles errors that occur in a consistent manner.  If
     called in command form and there is a failure, an error is thrown
     and a message printed.  If called in functional form, no error or
     message is printed and the failure is communicated to the programmer
     via the output status variable.

     The following list of functions have been modified.

     * `copyfile`
     * `fcntl`
     * `fileattrib`
     * `kill`
     * `link`
     * `mkfifo`
     * `movefile`
     * `rename`
     * `rmdir`
     * `symlink`
     * `unlink`

==========================================================================

You must change your script like this:

     [ret, status] = unlink ("nonexistent_file");

I am hereby closing this bug report. Please, feel free to reopen it if
you disagree with me.

Best,

Rafael Laboissière

#1103896#11
Date:
2025-04-22 16:06:47 UTC
From:
To:
Thank you Rafael.

There are two documentation issues here.  First, this is not what the manual says:

#1103896#16
Date:
2025-04-22 19:33:33 UTC
From:
To:
* Francesco Potortì <Potorti@isti.cnr.it> [2025-04-22 18:06]:

Fair enough. I am hereby reopening this bug report. Indeed, the
help documentation is incomplete.

Indeed, the documentation in NEWS.7.md is not perfect. It assumes
that when using the functional form, the user *always* collect the
status in an output variable.

I forwarded this bug report upstream.

Thanks,

Rafael Laboissière