1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

zsh: parse error near `&'

Posted at

事象 : curlのパラメータに「*」を入れたら怒られた

  • 環境
    • macOS BigSur バージョン11.3.1
    • zsh 5.8 (x86_64-apple-darwin20.0)

RedmineのRestAPIでチケット一覧を取得する時、status_idに「*」を指定することができる。

status_id: get issues with the given status id only. Possible values: open, closed, * to get open and closed issues, status id
Rest Issues - Redmine

status_idに「*」を指定してcurlコマンドでAPIを呼び出したら怒られた・・・

$ curl -X GET -H 'X-Redmine-API-Key:{APIキー}' {RedmineのURL}/issues.json?limit=100&sort=asc&status_id=*
zsh: parse error near `&'

原因 : 不明

status_id=*があっても他に指定するパラメータによっては怒られない、なんで?

# パラメータが「status_id」だけだとエラーにならない
$ curl -X GET -H 'X-Redmine-API-Key:{APIキー}' {RedmineのURL}/issues.json?status_id=* 
{"issues":[{"id":...

# パラメータが「limit」と「status_id」だとエラーにならない
$ curl -X GET -H 'X-Redmine-API-Key:{APIキー}' {RedmineのURL}/issues.json?limit=1&status_id=* 
{"issues":[{"id":...

# パラメータが「limit」と「issue_id」と「status_id」だとエラーになる
$ curl -X GET -H 'X-Redmine-API-Key:{APIキー}' {RedmineのURL}/issues.json?limit=1&issue_id=1&status_id=*
zsh: parse error near `&'

# 「*」を'(シングルクォーテーション)で囲ってもエラーだった・・・
$ curl -X GET -H 'X-Redmine-API-Key:{APIキー}' {RedmineのURL}/issues.json?limit=100&sort=asc&status_id='*'
zsh: parse error near `&'

対応 : URLを`で囲う

URLを「'(シングルクォーテーション)」で囲ったら怒られなかった・・・理由を知りたいがとりあえずいけた。

$ curl -X GET -H 'X-Redmine-API-Key:{APIキー}' '{RedmineのURL}/issues.json?limit=100&sort=asc&status_id=*' 
{"issues":[{"id":...
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?