ENVIRONMENT
xz parses space-separated lists of options from the environment vari‐
ables XZ_DEFAULTS and XZ_OPT, in this order, before parsing the options
from the command line. Note that only options are parsed from the en‐
vironment variables; all non-options are silently ignored. Parsing is
done with getopt_long(3) which is used also for the command line argu‐
ments.
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_DE‐ FAULTS.
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
when xz is run by a script or tool, for example, GNU tar(1):
XZ_OPT=-2v tar caf foo.tar.xz foo
Scripts may use XZ_OPT, for example, to set script-specific de‐
fault compression options. It is still recommended to allow
users to override XZ_OPT if that is reasonable. For example, in
sh(1) scripts one may use something like this:
XZ_OPT=${XZ_OPT-"-7e"} export XZ_OPT
From the zstd manpage:
Environment Variables
Employing environment variables to set parameters has security implica‐
tions. Therefore, this avenue is intentionally limited. Only
ZSTD_CLEVEL and ZSTD_NBTHREADS are currently supported. They set the
compression level and number of threads to use during compression, re‐
spectively.
ZSTD_CLEVEL can be used to set the level between 1 and 19 (the "normal"
range). If the value of ZSTD_CLEVEL is not a valid integer, it will be
ignored with a warning message. ZSTD_CLEVEL just replaces the default
compression level (3).
Have you tried environment variables?
From the xz manpage:
ENVIRONMENT
xz parses space-separated lists of options from the environment vari‐
ables XZ_DEFAULTS and XZ_OPT, in this order, before parsing the options
from the command line. Note that only options are parsed from the en‐
vironment variables; all non-options are silently ignored. Parsing is
done with getopt_long(3) which is used also for the command line argu‐
ments.
XZ_DEFAULTS
User-specific or system-wide default options. Typically this is
limiter by default. Excluding shell initialization scripts and
similar special cases, scripts must never set or unset XZ_DE‐
FAULTS.
set in a shell initialization script to enable xz's memory usage
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
when xz is run by a script or tool, for example, GNU tar(1):
fault compression options. It is still recommended to allow
users to override XZ_OPT if that is reasonable. For example, in
sh(1) scripts one may use something like this:
From the zstd manpage:
Environment Variables
Employing environment variables to set parameters has security implica‐
tions. Therefore, this avenue is intentionally limited. Only
ZSTD_CLEVEL and ZSTD_NBTHREADS are currently supported. They set the
compression level and number of threads to use during compression, re‐
spectively.
ZSTD_CLEVEL can be used to set the level between 1 and 19 (the "normal"
range). If the value of ZSTD_CLEVEL is not a valid integer, it will be
ignored with a warning message. ZSTD_CLEVEL just replaces the default
compression level (3).