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 %d fails for "08" and "09" but not for "01" to "07" #9035

Closed
eelcocramer opened this issue Jun 23, 2022 · 2 comments
Closed

printf %d fails for "08" and "09" but not for "01" to "07" #9035

eelcocramer opened this issue Jun 23, 2022 · 2 comments

Comments

@eelcocramer
Copy link

fish, version 3.5.0

❯ printf %d 07
7⏎                                                                                  
❯ printf %d 08
08: value not completely converted (can't convert '8')
0⏎                                                                                  
❯ printf %d 09
09: value not completely converted (can't convert '9')
0⏎                                                                                  
❯ printf %d 10
10⏎                                                                                 

So for i in (seq -w 1 10); printf "%d\n" $i; end prints:

❯ for i in (seq -w 1 10); printf "%d\n" $i; end
1
2
3
4
5
6
7
08: value not completely converted (can't convert '8')
0
09: value not completely converted (can't convert '9')
0
10
@faho
Copy link
Member

faho commented Jun 23, 2022

Unfortunately this is how printf is supposed to work. It reads the leading "0" as indicating an octal number.

Compare command printf %d 08, mine fails the same way.

@faho faho closed this as completed Jun 23, 2022
@faho faho added this to the will-not-implement milestone Jun 23, 2022
@eelcocramer
Copy link
Author

I see. You are right bash does the same but the error message explains that is an invalid octal number which makes it clear right away. I should have tried that first.

faho added a commit that referenced this issue Jun 23, 2022
(tbh these were always a mistake)

See #9035
zanchey pushed a commit that referenced this issue Jul 13, 2022
(tbh these were always a mistake)

See #9035

(cherry picked from commit 13a9f6b)
@faho faho modified the milestones: will-not-implement, fish 3.5.1 Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants