{"id":7899,"date":"2026-03-11T08:35:08","date_gmt":"2026-03-11T06:35:08","guid":{"rendered":"https:\/\/mummila.net\/kommentit\/?p=7899"},"modified":"2026-03-11T08:35:08","modified_gmt":"2026-03-11T06:35:08","slug":"changed-formatting-of-array-index-calculation-in-3-13-0-intended-or-not","status":"publish","type":"post","link":"https:\/\/mummila.net\/kommentit\/2026\/03\/11\/changed-formatting-of-array-index-calculation-in-3-13-0-intended-or-not\/","title":{"rendered":"Changed formatting of array index calculation in 3.13.0: intended or not?"},"content":{"rendered":"<p>With the same arguments given, output differs between 3.12.0 and 3.13.0, as demonstrated in the example below. I didn&#8217;t see this mentioned directly in the release notes, so I was wondering if this is an intentional change or a bug. I don&#8217;t mind the change per se, but just wanted to be sure that it&#8217;s permanent before I adjust all my existing scripts to conform to the newer way shfmt prefers this.<\/p>\n<pre><code>$ cat asdf\r\n#!\/bin\/bash\r\n\r\narray=(\r\n    \"a\"\r\n    \"b\"\r\n    \"c\"\r\n)\r\n\r\nvalue=\"${array[${#array[@]} - 1]}\"\r\n\r\nprintf \"%s\\n\" \"${value}\"\r\n\r\n$ \/usr\/local\/bin\/archive\/shfmt\/shfmt_v3.12.0_linux_amd64 -i 4 -ci -l -d asdf # no output\r\n\r\n$ \/usr\/local\/bin\/archive\/shfmt\/shfmt_v3.13.0_linux_amd64 -i 4 -ci -l -d asdf\r\nasdf\r\ndiff asdf.orig asdf\r\n--- asdf.orig\r\n+++ asdf\r\n@@ -6,6 +6,6 @@\r\n     \"c\"\r\n )\r\n \r\n-value=\"${array[${#array[@]} - 1]}\"\r\n+value=\"${array[${#array[@]}-1]}\"\r\n \r\n printf \"%s\\n\" \"${value}\"<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>With the same arguments given, output differs between 3.12.0 and 3.13.0. I was wondering if this is an intentional change or a bug.<\/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":[23032],"class_list":["post-7899","post","type-post","status-publish","format-standard","hentry","category-vianhallintajarjestelmat","tag-shfmt","sijainti-github"],"_links":{"self":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/7899","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=7899"}],"version-history":[{"count":1,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/7899\/revisions"}],"predecessor-version":[{"id":7900,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/7899\/revisions\/7900"}],"wp:attachment":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/media?parent=7899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/categories?post=7899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/tags?post=7899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}