【问题标题】:how to combine "-" and "--" options when starting octave?开始八度时如何组合“-”和“--”选项?
【发布时间】:2012-08-23 01:11:42
【问题描述】:

我注意到我无法将 --traditional 选项与另一个字母组合在一起,例如 -i

例如,当我将其作为 octave .m 文件的第一行时

#!/usr/bin/octave  --traditional 

然后它工作。 Octave 启动正常并运行脚本。

但是当我尝试时

#!/usr/bin/octave  --traditional --silent --norc --interactive

它不起作用。八度误差。不理解选项。

当我尝试时

#!/usr/bin/octave  --traditional -qfi

也是错误。但是这个

#!/usr/bin/octave  -qfi

有效。

问题是--traditional 没有像所有其他选项一样的单字母快捷方式。这是我看到的选项

Options:

  --debug, -d             Enter parser debugging mode.
  --doc-cache-file FILE   Use doc cache file FILE.
  --echo-commands, -x     Echo commands as they are executed.
  --eval CODE             Evaluate CODE.  Exit when done unless --persist.
  --exec-path PATH        Set path for executing subprograms.
  --help, -h, -?          Print short help message and exit.
  --image-path PATH       Add PATH to head of image search path.
  --info-file FILE        Use top-level info file FILE.
  --info-program PROGRAM  Use PROGRAM for reading info files.
  --interactive, -i       Force interactive behavior.
  --line-editing          Force readline use for command-line editing.
  --no-history, -H        Don't save commands to the history list
  --no-init-file          Don't read the ~/.octaverc or .octaverc files.
  --no-init-path          Don't initialize function search path.
  --no-line-editing       Don't use readline for command-line editing.
  --no-site-file          Don't read the site-wide octaverc file.
  --no-window-system      Disable window system, including graphics.
  --norc, -f              Don't read any initialization files.
  --path PATH, -p PATH    Add PATH to head of function search path.
  --persist               Go interactive after --eval or reading from FILE.
  --silent, -q            Don't print message at startup.
  --traditional           Set variables for closer MATLAB compatibility.
  --verbose, -V           Enable verbose output in some cases.
  --version, -v           Print version number and exit.

我主要对运行与 Matlab 兼容的 octave 代码感兴趣,所以我想使用这个 --traditional 选项来确保我的代码与 Matlab 兼容,以防我需要在 Matlab 中运行相同的代码也是。

或者,一旦 octave 开始使用不同的命令,我是否可以“打开”这种兼容模式?

我在 Linux 上使用 GNU Octave,版本 3.2.4。

谢谢

【问题讨论】:

    标签: octave


    【解决方案1】:

    我认为这本身并不是octave 问题。 Unix 的shebang 表示法通常有些限制。我不知道确切的限制,但我敢肯定,如果您在 shebang 行中添加多个选项,许多实现都会不满意,这似乎是您的问题。

    使用包装脚本可能是解决此类问题的规范方法。

    为了解决您结合短选项和长选项的问题,Unix 约定不允许这样做。如果这对您可行,您可以考虑修补octave--traditional 添加一个简短选项。或者,我想有一种方法可以在用户或系统范围的 Octave 配置文件中指定传统行为,但如果您需要脚本在您无法控制的系统上工作,这可能没有太大帮助。

    【讨论】:

    • 我通过使用“exec octave --traditional -q $@”创建一个包装脚本解决了这个问题,作为 $@ 基础
    猜你喜欢
    • 1970-01-01
    • 2018-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多