【发布时间】:2022-12-02 00:55:00
【问题描述】:
Problem
I'm trying to save a few CLI arguments into a variable, so it's convenient for me to use later. This works but is quite verbose:
-
flutter run --dart-define=SENTRY_DSN_CLIENT_KEY=${APP1_SENTRY_DSN_CLIENT_KEY} --dart-define=MAPBOX_ACCESS_TOKEN=${APP1_MAPBOX_ACCESS_TOKEN}
Unfortunately, neither of the following, concise options work. The 2nd --dart-define is not available in the app. I've tried:
flutter run $APP1_DART_DEFINE_FLAGS-
flutter run "${APP1_DART_DEFINE_FLAGS[@]}"
How do I workaround an issue which seems to be inside the flutter run tool?
Related problems
This seems to be highly related to (but I don't have control over fixing this):
- Documented as SC2128: Expanding an array without an index only gives the first element.
- in SO question
My env file
export APP1_SENTRY_DS=...
export APP1_MAPBOX_ACCESS_TOKEN=...
export APP1_DART_DEFINE_FLAGS="--dart-define=SENTRY_DSN_CLIENT_KEY=${APP1_SENTRY_DSN_CLIENT_KEY} --dart-define=MAPBOX_ACCESS_TOKEN=${APP1_MAPBOX_ACCESS_TOKEN}"
【问题讨论】:
-
in your
envfile you defineAPP1_SENTRY_DSbut when definingAPP1_DART_DEFINE_FLAGSyou reference a different variableAPP1_SENTRY_DSN_CLIENT_KEY; I can't tell if you have a typo in theenvfile, a typo in what you've posted in the question, or if there are more entries in yourenvfile that are not shown here ... ?? -
nowhere in the question do you show the creation/population of an array so not sure where the reference to
SC21281comes into play here; did you generate theSC2128and if so could you provide the complete set of code you supplied to shellcheck.net?
标签: bash