Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printf with gap in indexed conversion specifier try to fetch a number in the hole. #824

Open
phidebian opened this issue Feb 22, 2025 · 1 comment

Comments

@phidebian
Copy link

phidebian commented Feb 22, 2025

$ echo $KSH_VERSION
Version AJM 93u+m/1.1.0-alpha+b5087279 2025-01-15

$ printf '%s %5$s\n' 1 2 3
1

$ printf '%s %5$s\n' A B C
./arch/linux.i386-64/bin/ksh: printf: B: parameter not set
./arch/linux.i386-64/bin/ksh: printf: C: parameter not set
A

This is a leftover from ancient code...

Expected result

$ printf '%s %5$s\n' 1 2 3
1

$ printf '%s %5$s\n' A B C
A

@phidebian
Copy link
Author

Fixed with commit e322dbc

Apologies, in sftable.c I did the 1 char fix

fp[n].ft.fmt = 'd';

into

fp[n].ft.fmt = 'c';

But I forgot to update the comment
/* gap: pretend it's a 'd' pattern */

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant