| #!/bin/bash |
| # Copyright 2024 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| #### CATEGORY=Other |
| ### Run a custom combination of commands, able to take advantage of `fx -i` (iterative mode) |
| |
| ## usage: fx [-i] run-script "<command>" |
| ## |
| ## `<command>` can be any command that would be valid as a single line at a shell prompt. |
| ## For example, |
| ## |
| ## - Arbitrary shell commands: `fx -i run-script "ls | grep fuchsia"` |
| ## - Fuchsia commands: `fx -i run-script "ffx emu stop && fx build && ffx emu start"` |
| ## - Independent commands: `fx -i run-script "ls; find . -name test.rs"` |
| ## |
| ## Passing a regular shell script is not supported. |
| |
| |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $? |
| |
| if [[ $# -ne 1 ]]; then |
| fx-command-help |
| exit 1 |
| fi |
| |
| args=( "$@" ) |
| arg=${args[0]} |
| |
| if [[ $arg == "--help" || $arg == "-h" ]]; then |
| fx-command-help |
| exit 1 |
| fi |
| |
| lib_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh |
| bash -c "source $lib_path && $@" |