Den 2021-07-07 kl. 10:16 skrev Valtteri Vuorikoski: >> Ah! There is a simpler solution: >> >> echo .ds head-str ${str#"${str%?}"} >> >> Now that's elegant... and POSIX-compatible. >> >> Note the necessary quotation marks around ${str%?} >> (in case $str contains glob characters). > > Nice solution, it fixes the macro for my test file.
I should add that I forgot quotation marks around the whole thing. It might also expand to a glob character... The correct code is echo .ds head-str "${str#"${str%?}"}"