* Chet Ramey <[EMAIL PROTECTED]> [2008-03-17 22:57]: >> Can you elaborate on the differences in case they're the cause of other >> strange behaviours? > > 1. Backslashes should not be stripped within single quotes. > > 2. Backslashes should only be stripped within double quotes if they're > followed by one of $ ` " \ <newline>
Ah, that's the reason for this behaviour then (using your quote func.): [EMAIL PROTECTED]:~/rrr$ compgen -f $(quote "STORE") STORE\'N\'GO STORE'N'GO [EMAIL PROTECTED]:~/rrr$ compgen -f $(quote "STORE'") STORE'N'GO [EMAIL PROTECTED]:~/rrr$ compgen -f $(quote "STORE\'") [EMAIL PROTECTED]:~/rrr(1)$ compgen -f $(quote "STORE\\'") [EMAIL PROTECTED]:~/rrr(1)$ compgen -f $(quote "STORE\\\'") STORE\'N\'GO So I guess I would not need the quote fuction but a function that quotes the way compgen unquotes :) I tried this and it seems to work: quote2() { local t=${1//\\/\\\\} echo \'${t//\'/\'\\\'\'}\' } [EMAIL PROTECTED]:~/rrr$ for i in test*; do echo -n "${i:0:5}: "; compgen -f "$(quote2 "${i:0:5}")"; done test`: test`test test : test test test': test'test test": test"test test$: test$test test\: test\test Something like this could be useful as a workaround for older versions of bash. Comments? > OK, I attached a patch. On first sight this seems to work well: [EMAIL PROTECTED]:~/rrr(1)$ compgen -f "STORE" STORE\'N\'GO STORE'N'GO [EMAIL PROTECTED]:~/rrr$ compgen -f "STORE'" STORE'N'GO [EMAIL PROTECTED]:~/rrr$ compgen -f "STORE\'" STORE\'N\'GO [EMAIL PROTECTED]:~/rrr$ compgen -f "STORE\\'" STORE\'N\'GO [EMAIL PROTECTED]:~/rrr$ compgen -f "STORE\\\'" [EMAIL PROTECTED]:~/rrr(1)$ [EMAIL PROTECTED]:~/rrr(1)$ for i in test*; do echo -n "${i:0:5}: "; compgen -f "${i:0:5}"; done test`: test`test test : test test test': test'test test": test"test test$: test$test test\: test\test I'll test it a bit more tomorrow. Thanks a lot for now! Regards, Mika