record: skip whitespaces after shebang for scripts#1789
record: skip whitespaces after shebang for scripts#1789GabrielKimm wants to merge 1 commit intonamhyung:masterfrom
Conversation
6aa6180 to
534a366
Compare
|
Hi, I think we can keep |
Hi. I'm asking to check if it's the part I understand. |
|
No, I mean the opposite. The str_ltrim(s);
str_rtrim(s); |
e5d3207 to
0ec6cfa
Compare
|
As you said, I changed it to call |
0ec6cfa to
1ce1ff8
Compare
|
I modified the code to call Would it be good to add a |
namhyung
left a comment
There was a problem hiding this comment.
Your commit has unrelated changes. Please check.
1ce1ff8 to
0ff461e
Compare
|
Oh! I'm sorry. I modified it to Commit except for the unrelated changes. |
0e9aafa to
00300fd
Compare
Python tracing won't work when the shebang line has a space like below: " #! /usr/bin/env python3 " This patch makes uftrace to understand the above shebang as well. Fixed: namhyung#1690 Signed-off-by: Gabriel Kim <0xgabriel.kim@gmail.com>
00300fd to
7df908a
Compare
|
Hello, I've implemented a new function called
This structure enhances modularity and reusability, and it also solves the issue regarding shebang lines that have more than one space between characters. As for mentioning issue numbers, there has been some discussion whether to mention Thank you for your time and consideration. |
|
I think it's ok.. but not clear what the problem was. Do you have an error message without this change or command line output before and after it? |
Thank you for reviewing the PR and for your feedback. Initially, only str_ltrim was utilized for handling shebang lines, leaving us with the ability to only trim leading whitespaces. Although str_rtrim was implemented, it was not actually called, making it ineffective for trimming trailing whitespaces. This was a limitation highlighted in the discussion started by honggyukim in #1697. Comment Link : https://github.com/namhyung/uftrace/pull/1697#issuecomment-1552964734 To rectify this, we've incorporated both str_ltrim and str_rtrim to handle leading and trailing whitespaces, respectively. The need for handling these trailing whitespaces was particularly emphasized by honggyukim and was not possible in our earlier implementation. I hope this clarifies the issue we're trying to solve. Would it be useful if I provided some before-and-after command-line outputs for further clarification? |
|
Yes, please. |
Before this PRCase 1: Multiple leading whitespaces
Case 2: Multiple trailing whitespaces
Case 3: Multiple whitespaces in the middle
Case 4: Multiple whitespaces at all positions
After this PRCase 1: Multiple leading whitespaces
Case 2: Multiple trailing whitespaces
Case 3: Multiple whitespaces in the middle
Case 4: Multiple whitespaces at all positions
|
|
I think you can write an unittest for the above testing. You can learn more about how to write unittest by reading https://github.com/namhyung/uftrace/blob/v0.14/utils/demangle.c#L1793-L1826. The unittest can be compiled and executed as follows. You can simply run a single unittest as follows. |
|
I wanted to see actual case with spaces in the hash bang which failed to run before this change and passed after that. Maybe something like this: |
Hello, @GabrielKimm, In shebang Wikipedia,
|
|
Thank you for your feedback, @namhyung @MichelleJin12. Here's what I found: Before this PR
|
|
Thank you for the feedback, @honggyukim. I recognize the importance of ensuring the shebang line's space handling works as intended. I'm in agreement that creating an automated unittest for this will be beneficial. Having looked into the link you provided, I have a better understanding of how to structure the unittest for uftrace. I'll proceed to write the unittest to verify the shebang line's space handling and update the PR once completed. Thank you for guiding me towards ensuring better code quality. |
Python tracing won't work when the shebang line has a space like below:
" #! /usr/bin/env python3 "
This patch makes uftrace to understand the above shebang as well.
Fixed: #1690
Signed-off-by: Gabriel Kim 0xgabriel.kim@gmail.com