pub fn aur_install_shell_fallback<S: AsRef<str>>(
names: &[S],
options: &InstallOptions,
) -> Result<String>Expand description
What: Build a shell body that installs AUR packages with runtime helper fallback.
Inputs:
names: AUR package names to install (validated).options: Flag options (needed,noconfirm,aur_only).
Output:
Ok(String)with a POSIX shell snippet that picksparu, thenyay, at execution time, or printsNO_AUR_HELPER_MESSAGE.
Details:
- Unlike
build_aur_install, helper selection happens inside the spawned shell (the terminal’sPATH), not in the calling process — matching Pacsea’saur_install_body. Prefer this when the command runs in an external terminal whose environment may differ from the caller’s. - Names pass the same strict validation as all builders, so interpolating
them into the shell string is safe without quoting. A
--operand terminator is emitted before the names for defense in depth. - When neither helper exists the body writes
NO_AUR_HELPER_MESSAGEto stderr and exits the subshell with status 127, so callers see a failure instead of a successful no-op.
§Errors
Returns ArchToolkitError::InvalidPackageName when a name fails validation,
or ArchToolkitError::EmptyInput when names is empty.
§Example
use arch_toolkit::install::aur_install_shell_fallback;
use arch_toolkit::types::install::InstallOptions;
let body = aur_install_shell_fallback(&["yay-bin"], &InstallOptions::default())?;
assert!(body.contains("if command -v paru >/dev/null 2>&1; then paru"));
assert!(body.contains("elif command -v yay >/dev/null 2>&1; then yay"));
assert!(body.contains("--noconfirm -- yay-bin"));
assert!(body.contains("exit 127"));