-
Notifications
You must be signed in to change notification settings - Fork 178
Update linux_procmemdump.sh #320
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
base: develop
Are you sure you want to change the base?
Conversation
replaced some stuff like echo with printf restrict error handling etc …
|
After some tests I noticed it is failing to collect the sections/maps after the changes. Can you test the following, please?
|
|
What system are you using for testing it? Here it is still failing to collect the memory sections. |
|
Hi, I know I'm new here, but I have some points to talk about.
O.k., great, but look: was there a real necessity of replacing Now this caught my attention: -- mkdir -p "${outputdir}"
++ sudo mkdir -p -v "${outputdir}"Not every machine has I saw that you've implemented a function called In any case, this will need some fixes to be merged. If I were you, I would have this as a draft pull-request to work in until it gets ready to be reviewed and merged. |
sorry about my bugs! hints to echo vs printf ## POSIX Comparison: `echo` vs `printf`
### Overview
Both `echo` and `printf` are used to output text in shell scripts, but they differ significantly in **portability**, **predictability**, and **POSIX compliance**.
---
### POSIX Compliance and Portability
| Feature | `echo` | `printf` |
|-----------------------|----------------------------------------------------|------------------------------------------|
| **POSIX Standard** | Loosely defined; behavior varies | Strictly defined and consistent |
| **Options** | Handling of options (e.g., `-n`, `-e`) is implementation-defined | No options; format string required |
| **Escape Sequences** | Handling is not standardized; may require `-e` or be unsupported | Well-defined (e.g., `\n`, `\t`, etc.) |
| **Output Consistency**| Varies between shells and systems | Consistent across POSIX systems |
| **Suppress Newline** | `-n` flag (not always portable) | Omit `\n` in format string |
---
### Key Differences
#### `echo`
- **Not fully standardized**: Different shells and systems interpret `echo` flags and escape sequences differently.
- **Ambiguity with input**: If the string starts with `-`, it may be treated as an option.
- **Escape sequences**: Some require `-e` to interpret escapes, others do not; some do not support escapes at all.
- **Portability**: Only reliably outputs plain text without options or escapes.
- **Use case**: Suitable for simple, controlled output where portability is not a concern.
#### `printf`
- **Strictly POSIX-compliant**: Format and behavior are well-defined by POSIX.
- **No ambiguity**: Always interprets the first argument as a format string, so values starting with `-` are not problematic.
- **Predictable escape handling**: Recognizes standard C-style escapes in the format string.
- **Suppressing newline**: Simply omit `\n` from the format string.
- **Portability**: Preferred for scripts intended to run on any POSIX-compliant system.
- **Use case**: Recommended for all scripting where output may include variables, special characters, or needs to be portable.
---
### Practical Examples
#### Printing a variable that may start with `-` or contain backslashes
Using echo (unreliable)echo "$var" Using printf (reliable)printf '%s\n' "$var" echo (may not be portable)echo -n "No newline" printf (portable)printf '%s' "No newline" |
No problem, just take care of them and inquire for help if necessary.
I know about these problems, but thanks for clarifying. I just questioned about how these problems happened in the code, I hadn't seen any complaint about it before. |
replaced some stuff like echo with printf
restrict error handling
etc …