如何为 xz 归档器设置默认参数?
How to set default params for xz archiver?
默认情况下 xz
压缩器使用单线程(例如,从 AUR 压缩新创建的包)。有一个 --threads
使用更多线程的选项。
在哪里可以设置 xz 的全局设置,以便将线程选项设置为我的值?在 man 中找不到任何信息。
手册页确实谈到了为此目的使用环境变量:
ENVIRONMENT
xz parses space-separated lists of options from the environment variables XZ_DEFAULTS
and XZ_OPT, in this order, before parsing the options from the command line. Note
that only options are parsed from the environment variables; all non-options are
silently ignored. Parsing is done with getopt_long(3) which is used also for the
command line arguments.
XZ_DEFAULTS
User-specific or system-wide default options. Typically this is set in a
shell initialization script to enable xz's memory usage limiter by default.
Excluding shell initialization scripts and similar special cases, scripts must
never set or unset XZ_DEFAULTS.
XZ_OPT This is for passing options to xz when it is not possible to set the options
directly on the xz command line. This is the case e.g. when xz is run by a
script or tool, e.g. GNU tar(1):
XZ_OPT=-2v tar caf foo.tar.xz foo
Scripts may use XZ_OPT e.g. to set script-specific default compression op‐
tions. It is still recommended to allow users to override XZ_OPT if that is
reasonable, e.g. in sh(1) scripts one may use something like this:
XZ_OPT=${XZ_OPT-"-7e"}
export XZ_OPT
看起来 XZ_DEFAULTS
会如你所愿。
默认情况下 xz
压缩器使用单线程(例如,从 AUR 压缩新创建的包)。有一个 --threads
使用更多线程的选项。
在哪里可以设置 xz 的全局设置,以便将线程选项设置为我的值?在 man 中找不到任何信息。
手册页确实谈到了为此目的使用环境变量:
ENVIRONMENT
xz parses space-separated lists of options from the environment variables XZ_DEFAULTS
and XZ_OPT, in this order, before parsing the options from the command line. Note
that only options are parsed from the environment variables; all non-options are
silently ignored. Parsing is done with getopt_long(3) which is used also for the
command line arguments.
XZ_DEFAULTS
User-specific or system-wide default options. Typically this is set in a
shell initialization script to enable xz's memory usage limiter by default.
Excluding shell initialization scripts and similar special cases, scripts must
never set or unset XZ_DEFAULTS.
XZ_OPT This is for passing options to xz when it is not possible to set the options
directly on the xz command line. This is the case e.g. when xz is run by a
script or tool, e.g. GNU tar(1):
XZ_OPT=-2v tar caf foo.tar.xz foo
Scripts may use XZ_OPT e.g. to set script-specific default compression op‐
tions. It is still recommended to allow users to override XZ_OPT if that is
reasonable, e.g. in sh(1) scripts one may use something like this:
XZ_OPT=${XZ_OPT-"-7e"}
export XZ_OPT
看起来 XZ_DEFAULTS
会如你所愿。