4 ms·
> And the sed regex does not support stuff like + Are you talking about BSD sed here, because GNU sed does support + with the -r flag.
by keeperofdakeys 14y ago
> And the sed regex does not support stuff like +
Are you talking about BSD sed here, because GNU sed does support + with the -r flag.
- drothlis 14y agoThe problem is that it's hard to use sed portably, because GNU sed's "-r" is "-E" in BSD sed. (There's also the differing behaviour of "-i" as mentioned earlier in the thread.)
- emidln 14y agoNot it's not. GNU Sed compiles pretty much everywhere. Just use that.
- ygjb 14y agoYou just made his point.
- eyko 14y agoAnd nobody seems to have mentioned the fact that to run this script you'll need to install node and npm (although you can argue that node comes with npm, but anyway…). You might as well just install GNU sed in BSD if that's the problem. Also, I believe GNU sed is much faster than any javascript script. Moreover, if you want to use this as part of your node app, then it's a good reason to reimplement some of sed's functionality. I still don't see why you'd laugh or ridicule someone else for doing something like this, and sharing it (if anything at all, it serves as a good tutorial on file manipulation with javascript/node IO.
- protomyth 14y ago"You might as well just install GNU sed in BSD if that's the problem" Often not possible depending on what authorizations and hosting you have.
- papsosouid 14y agoWhat are you talking about? Yes, GNU bloatware is massive and hideous, but it is still far easier to install than javascript + framework + package manager + package. If you don't have the ability to run binaries in ~/bin then you can't use this sed alternative either.
- protomyth 14y agoI took it that I already had node.js installed because that's what we were using. Asking for a replacement for an already existing sed is probably not going to happen.
- papsosouid 14y agoYou don't need to ask unless /home is mounted noexec. It seems rather absurd to assume a seldom used and rather massive ecosystem of language, libs, framework and package manager are installed, but that it is impossible to upload a copy of gsed to ~/bin. The number of shared hosting environments where you can't run your own code, and you already have node installed is miniscule. And although its getting a bit off-topic at this point, doing replacements directly in the file isn't even a good idea. The standard "move $file to $file.backup, run sed against $file.backup and pipe it into $file" method is not just recommended because it is portable, it also saves your ass when you messed up your search+replace and broke all your files.
- protomyth 14y ago"You don't need to ask unless /home is mounted noexec." You'd be surprised what is restricted in a lot of corps beyond the "approved" software list. It is amazing what big things get approved and what little things don't.
- papsosouid 14y agoNo I wouldn't, I've dealt with them extensively. I have no idea how that is relevant though. If Enterprositous Corp X needs a way to do replacements, they install one. They would have to install node and a ton of other crap anyways, why do you pretend installing a single trivial binary is beyond hope of possibility, but installing a huge language+framework ecosystem is totally cool?
- krzyk 14y agoOr by escaping: \+ I didn't even know there is a -r option, I always escaped the plus sign (and parentheses)