[SOLVED] Percent symbols in posts sometimes require escape sequences, sometimes do not
LQ Suggestions & FeedbackDo you have a suggestion for this site or an idea that will make the site better? This forum is for you.
PLEASE READ THIS FORUM - Information and status updates will also be posted here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Percent symbols in posts sometimes require escape sequences, sometimes do not
Bear with my characterizations, I expect to post, reply, reply again, and then edit the second reply, and then probably post a fourth message to summarize.
I noticed that a percent symbol I used as part of a reply was missing. "Oops!" have to escape that, I originally thought with the backslash, but instead I needed to double it by using "percent-percent" and that worked.
Later I re-edited my edit because I corrected something and I reminded myself "double percent's" and (swear word) it put up the double! So I iterated and by that point it seemed to recognize the single use. But ... I did my first edit because it obliterated a single use ....
So as I say. This post will contain a test single percent, and then a double percent.
Reply #1 will just be a simple reply using the same test cases.
Reply #2 will be an advanced editor use reply using the same test cases.
Reply #3 will be a summary.
And I'm sitting here ready to eat crow and just finalize by clicking [SOLVED] if I'm all full of (junk) when the testing is complete.
Single percent %
Double percents %%
---------- Post added 09-02-15 at 10:47 AM ----------
Sorry, I marked as solved but didn't state any conclusions. I did see the other thread, I think also referenced earlier, and see that the subject was addressed already.
So readers maybe thought: either Didier can't write a simple shell script or he didn't take care of trying it before posting.
PS I realize that such a change on a website with a very high load needs thorough testing before being put in production "in the wild". I volunteer to participate to these tests as an end user who can devote some time to such a task.
Last edited by Didier Spaier; 11-02-2015 at 09:36 AM.
Reason: PS added.
Didier is right to highlight the risks here. Having the percent signs silently ripped from a ${parameter%word} or ${parameter%%word} substitution in a posted shell-script example could potentially do much more harm than just making the poster look like an idiot.
This is somewhat contrived and not a particularly good/safe coding style to start with, but take the following example of a not entirely unreasonable installation routine (minus the echo's which I've thrown in just to be 100% safe):
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602
Rep:
I'm happy to report that a fix to this issue has been rolled out. I appreciate the patience. A big thanks to Stuart Langridge for the pointer that ended up leading to the solution.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.