{"id":6629,"date":"2021-05-04T12:13:44","date_gmt":"2021-05-04T09:13:44","guid":{"rendered":"https:\/\/mummila.net\/kommentit\/?p=6629"},"modified":"2021-05-04T12:13:44","modified_gmt":"2021-05-04T09:13:44","slug":"indent-outdent-mismatch-when-using-multi-line-array-assignment-inside-case-esac","status":"publish","type":"post","link":"https:\/\/mummila.net\/kommentit\/2021\/05\/04\/indent-outdent-mismatch-when-using-multi-line-array-assignment-inside-case-esac\/","title":{"rendered":"indent\/outdent mismatch when using multi-line array assignment inside case&#8230;esac"},"content":{"rendered":"<p>My go-to way of quickly parsing arguments is as follows:<\/p>\n<pre><code>#!\/bin\/bash                                                                  \r\n                                                                             \r\nquiet=\"true\"                                                                 \r\nfiles=()                                                                     \r\n                                                                             \r\nfor arg in \"${@}\"; do                                                        \r\n    case \"${arg}\" in                                                         \r\n        \"-v\" | \"--verbose\")                                                  \r\n            quiet=\"false\"                                                    \r\n            ;;                                                               \r\n        *)\r\n            files+=(                                                         \r\n                \"${arg}\"                                                     \r\n            )                                                                   \r\n            ;;                                                               \r\n    esac                                                                     \r\ndone                                                                         \r\n<\/code><\/pre>\n<p>Beautysh (v6.1.0) incorrectly reports this as indent\/outdent mismatch and instead indents it like so:<\/p>\n<pre><code>#!\/bin\/bash                                                                  \r\n                                                                             \r\nquiet=\"true\"                                                                 \r\nfiles=()                                                                     \r\n                                                                             \r\nfor arg in \"${@}\"; do                                                        \r\n    case \"${arg}\" in                                                         \r\n        \"-v\" | \"--verbose\")                                                  \r\n            quiet=\"false\"                                                    \r\n            ;;                                                               \r\n        *)                                                                   \r\n            files+=(                                                         \r\n                \"${arg}\"                                                     \r\n            )                                                                \r\n                ;;                                                           \r\n        esac                                                                 \r\n    done\r\n<\/code><\/pre>\n<p>The deciding factor seems to be the multi-line parenthesis in assigning\u00a0<code>files<\/code>. If I assign it all on one line, like this:<\/p>\n<pre><code>            files+=(\"${arg}\")                                                \r\n<\/code><\/pre>\n<p>then beautysh is satisfied with the indentation (i.e. doesn&#8217;t change it or report a mismatch).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If I assign it all on one line, files+=(&#8221;${arg}&#8221;), then beautysh is satisfied with the indentation (i.e. doesn&#8217;t change it or report a mismatch).<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8860],"tags":[9864],"class_list":["post-6629","post","type-post","status-publish","format-standard","hentry","category-vianhallintajarjestelmat","tag-bash","sijainti-github"],"_links":{"self":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/6629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/comments?post=6629"}],"version-history":[{"count":1,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/6629\/revisions"}],"predecessor-version":[{"id":6630,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/6629\/revisions\/6630"}],"wp:attachment":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/media?parent=6629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/categories?post=6629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/tags?post=6629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}