Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax error, unexpected QQSTRING_START with jq 1.3 from Ubuntu 14.04 repos #166

Open
asnelling opened this issue Jun 30, 2019 · 1 comment

Comments

@asnelling
Copy link

The scripts, in my case ./execute-all.sh, produce the following error upon invoking jq version 1.3:

error: syntax error, unexpected QQSTRING_START, expecting $end
."supported-apis"[]
 ^
1 compile error
./execute-all.sh: line 290: supportedAPIs[@]: unbound variable

Sure, the latest release of jq is 1.6, but version 1.3 ships with the official repositories in the environment recommended by the Android team: Ubuntu LTS 14.04 - Trusty

...and I didn't notice ./hostTools/Linux/bin/jq sitting in this repo until I already started digging in.

Seems like there was some confusion regarding which is the correct syntax (see jqlang/jq#273), but it seems that wrapping the object accessor is at least more correct and may save some people valuable debugging time when they start to build the AOSP tree.

Attached is a shell script to reproduce the error when executed in an ubuntu:14.04 Docker image.

asnelling added a commit to asnelling/android-prepare-vendor that referenced this issue Jun 30, 2019
@asnelling
Copy link
Author

From FAQ - General Questions in the jq repo:

𝑸: How can I access the value of a key with hyphens or $ or other special characters in it? Why does .a.["$"] produce a syntax error?

A: The basic form for accessing the value of a key is .["KEYNAME"] where "KEYNAME" is any valid JSON string, but recent versions of jq also allow ."KEYNAME".

So I imagine that, given a hyphenated key, such as "supported-apis", this syntax below is not compatible with the version 1.3

jq -r ".\"$query\"[]" "$conf_file" || {

Whereas this bracketed syntax is still valid and should work with previous versions of jq:

$ jq -r ".[\"$query\"] | .[]" "$conf_file"

# which after parameter expansion will become:
$ jq -r .["supported-apis"] | .[]  ./file...

asnelling added a commit to asnelling/android-prepare-vendor that referenced this issue Jul 20, 2019
asnelling added a commit to asnelling/android-prepare-vendor that referenced this issue Jul 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant