Re: How do you survive without notmuch?
On 2016-04-07, bastian-muttu...@t6l.dewrote: > On 07Apr16 19:53 +0200, Andreas wrote: >> Am 07.04.2016 um 01:19 schrieb Cameron Simpson: >> > Usually when I reach for notmuch it is because I have mismanaged my >> > folders. Hmm, that message about blah isn't there - where is it? > > Here, just a quick glimpse into my experience. > I discovered an easy way of life, at the time I stopped to sort my mails > into folders - either manually or automatically. For me it was just one > big source of failures. Mails could sometimes be sorted into multiple > folders, so where should I look to find that one again? And what the > heck is the sent-folder for? It just rips threads apart. rest snipped. Thanks for this post. I've been struggling with folders in mutt for the past several days and am going to give it up and move to an indexer, probably notmuch. Oliver
Re: How do you survive without notmuch?
On Sat, Apr 16, 2016 at 11:50:16AM +1000, c...@zip.com.au wrote: > On 14Apr2016 12:23, derek martinwrote: > [...snip...] > >IIRC there's a terminal-based web browser that has the ability to > >So even better HTML mail support should be doable in Mutt > >without making it a GUI... > > Having mutt ship with more flexible default configurations would > help. There are plenty of recipes floating around for "use w3m or > lynx to render HTML as plain text and page that", but they don't > ship with mutt itself - every user must pick a recipe and implement > it. The trouble with those recipes is they're all bad, for one reason or another. Some of it is due to how they render HTML (with margins, or with text justification, etc.) which is great for web pages, but mostly undesirable for e-mail. Or with certain elements being supported poorly. Some of it has to do with assumptions about character sets that are wrong and hard to fix. Though, some of the solutions are better than others... > >But I would frankly like to see a GUI option as well; I think it > >would be great if Mutt could switch back and forth and have a > >relatively consistent UI in both cases. It's totally doable. This > >is the kind of stuff that a modern mailer is > >expected to have... > > Doable portably would imply shipping an optional GUI kit with mutt; > and X11 is not the only desktop environment; [...] I'm no expert here but WX Windows (I think?) comes to mind... If I'm not imagining things there are such toolkits that basically wrap whatever's commonly available "natively" (which isn't really a concept on Linux, as it always has many to choose from). But it's a valid point. > For many of us mutt is text, letting us remain in our flexible > terminal environments without the mouse happy glaring white hassle > of a GUI, and it might be an anathema to give mutt any kind of > "native" GUI facility. Poppycock! By which I mean yes... :) I too mostly want to use Mutt that way, particularly since I use it over ssh to a server that's not even on the same continent I'm on. But with a modular design there's no reason you couldn't still have this and have a GUI be an option, without the folks who disdain such modern trappings even noticing. And they don't need to be glaringly white, FWIW. =8^) > I had the unpleasant experience of finding an Emoji rendered in my > mutt index listing a week or so ago, and I thought the End Times had > come. Thank you, Unicode Consortium. Thank you indeed! The world is too complex to live by ASCII alone. Unicode has made it (mostly) trivial for me to type my native English full time, while being simple to switch to Korean when I have the need or desire. Which is far less often than in the past, but still happens occasionally. :) > But I agree it would be good if more of the "extension" facilities > we use with mutt were available _easily_ to new users. Yeah. But nowadays, to most people, that means GUI. Which is about half of why I'd like to see that be an option. > Nothing is impossible for the man who doesn't have to do it. That is the truth! -- Derek D. Martinhttp://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience. pgpnQpFoJvxdI.pgp Description: PGP signature
Re: How do you survive without notmuch?
On 14Apr2016 12:23, derek martinwrote: [...snip...] IIRC there's a terminal-based web browser that has the ability to display web pages, including images, in your terminal window--though it may require the use of some specific terminal program, I can't recall. I'm using iTerm 3 beta on OSX, and it is capable of displaying images. Mutt would probably need to allow certain extra ANSI-like codes through in the pager, _and_ grow some special support for recognising such things. Displaying web pages had traditionally been handled by handing the page content off to an external view "pop this message text up in firefox" for example. That could be made easier or better supported: all such actions require writing the message text (and possibly assets, such at attached images) into a temporary file or directory and calling the external viewer with the pathname in some fashion eg a "file:///" URL. The catch is that mutt normally removes such things when done, and with an asynchronous tool like a browser "done" is ill defined. So a facility for mutt to spawn a helper process to track this and then clean up, or not clean up, might be useful; then one could package some default behaviours with mutt built on such a thing. So even better HTML mail support should be doable in Mutt without making it a GUI... Having mutt ship with more flexible default configurations would help. There are plenty of recipes floating around for "use w3m or lynx to render HTML as plain text and page that", but they don't ship with mutt itself - every user must pick a recipe and implement it. But I would frankly like to see a GUI option as well; I think it would be great if Mutt could switch back and forth and have a relatively consistent UI in both cases. It's totally doable. This is the kind of stuff that a modern mailer is expected to have... Doable portably would imply shipping an optional GUI kit with mutt; and X11 is not the only desktop environment; while I can run X11 on this Mac it is more seamless with native apps. So a toolkit which knew about multiple platforms migh be necessary eg Qt; IIRC there are licencing issues there in addition to the loud debate about the GUI kit and whether to ship it at all. For many of us mutt is text, letting us remain in our flexible terminal environments without the mouse happy glaring white hassle of a GUI, and it might be an anathema to give mutt any kind of "native" GUI facility. I had the unpleasant experience of finding an Emoji rendered in my mutt index listing a week or so ago, and I thought the End Times had come. Thank you, Unicode Consortium. But I agree it would be good if more of the "extension" facilities we use with mutt were available _easily_ to new users. Cheers, Cameron Simpson Nothing is impossible for the man who doesn't have to do it.
Re: How do you survive without notmuch?
On Wed, Apr 13, 2016 at 04:30:27PM -0700, Will Yardley wrote: > I'm not as much worried about bloat, especially if it's an optional > feature, but it seems like something that would be fairly difficult to > implement in a way that is both fast and useful. > > For me, the bigger areas where I find Mutt limiting are things like > responding to Exchange / Gcal invites (though mostly just use Apple > products for this now), not being able to view images inline, etc. Given > how much less email is used these days (relative to text message, > Facebook messaging, online forums / FB groups, Slack, etc.), the emails > I *do* still get tend to be weighted more heavily in this direction than > they used to be. That said, I still much prefer Mutt over GUI MUAs. I agree with all these points. I'd like to see Mutt additionally have functionality to address all of these, plus the ability to easily add new mail store types via a unified mailbox driver API. It's obviously possible, but I suspect that to make it maintainable would require rewriting a lot of the core of Mutt. IIRC there's a terminal-based web browser that has the ability to display web pages, including images, in your terminal window--though it may require the use of some specific terminal program, I can't recall. So even better HTML mail support should be doable in Mutt without making it a GUI... But I would frankly like to see a GUI option as well; I think it would be great if Mutt could switch back and forth and have a relatively consistent UI in both cases. It's totally doable. This is the kind of stuff that a modern mailer is expected to have... -- Derek D. Martinhttp://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience. pgp940ocAjQiS.pgp Description: PGP signature
Re: How do you survive without notmuch?
On Wed, Apr 13, 2016 at 04:20:09PM -0500, Derek Martin wrote: > On Wed, Apr 13, 2016 at 08:05:52PM +1000, Erik Christiansen wrote: > > On 12.04.16 13:05, Derek Martin wrote: > > > On Tue, Apr 12, 2016 at 05:28:08PM +1000, Erik Christiansen wrote: > > > > The really big benefit of the Unix approach is that the same > > > > utility know-how can be applied to every problem, as it is only > > > > the mix of utilities used, and their parameters, which vary. > > > The downside is that typical users don't want to learn all those > > > tools, and by and large have no reason to. They use the web and > > > e-mail, and very little else. > If your software can save your user base gobs of configuration time > and learning curve, and simplify your tasks with a uniform, consistent > interface, how is that EVER a bad thing? Is that not actually the > entire point of software? Frankly, I know a number of people who have > moved on from Mutt cheifly because they were dissatisfied with its > search capabilities. And these are system programmers and > sysadmins--hardly the typical user. So clearly, just because it works > for YOU, doesn't mean it should be sufficient for everyone. > > The Unix Philosophy is a wonderful generalized solution, but it's well > understood that a specialized solution CAN be more efficient, and > provide additional usability and other benefits as well. I do agree with this, for the most part. While Mutt is definitely a project that appeals to techy sorts, and while the "building blocks" approach has a lot of benefits, there are times where the lack of tight integration becomes a problem. With search, especially, I think that's the case. I tried to setup Mairix with Mutt a long time ago, and found that it was way too kludgy to really be useful in the same way that the search in most GUI MUAs is. As mentioned before, using grep or Mutt's single mailbox search tends to work well for me in most cases, I also occasionally use my iPhone to search mail. Being able to do searches across all mailboxes directly within Mutt (ideally with some subset of the 'simple patterns'), especially over IMAP, would probably be a useful feature to many. I'm not as much worried about bloat, especially if it's an optional feature, but it seems like something that would be fairly difficult to implement in a way that is both fast and useful. For me, the bigger areas where I find Mutt limiting are things like responding to Exchange / Gcal invites (though mostly just use Apple products for this now), not being able to view images inline, etc. Given how much less email is used these days (relative to text message, Facebook messaging, online forums / FB groups, Slack, etc.), the emails I *do* still get tend to be weighted more heavily in this direction than they used to be. That said, I still much prefer Mutt over GUI MUAs. w
Re: How do you survive without notmuch?
On Wed, Apr 13, 2016 at 08:05:52PM +1000, Erik Christiansen wrote: > On 12.04.16 13:05, Derek Martin wrote: > > On Tue, Apr 12, 2016 at 05:28:08PM +1000, Erik Christiansen wrote: > > > The really big benefit of the Unix approach is that the same utility > > > know-how can be applied to every problem, as it is only the mix of > > > utilities used, and their parameters, which vary. > > > > The downside is that typical users don't want to learn all those > > tools, and by and large have no reason to. They use the web and > > e-mail, and very little else. > > Yes, what could be inferred from your first reply is now explicit. > May your typicality serve you well, and the rest of us tolerate what the > other has learned first and uses best. Come on, Erik, this response would be kind of insulting, if it weren't pretty ridiculous. I am far from typical... but we're not discussing what's good for you, or for me--we're discussing what's good for an entire user community. Your response provides zero value on that score, and completely ignored a very real deficiency I described which your solution utterly fails to solve. Why bother even replying? If your software can save your user base gobs of configuration time and learning curve, and simplify your tasks with a uniform, consistent interface, how is that EVER a bad thing? Is that not actually the entire point of software? Frankly, I know a number of people who have moved on from Mutt cheifly because they were dissatisfied with its search capabilities. And these are system programmers and sysadmins--hardly the typical user. So clearly, just because it works for YOU, doesn't mean it should be sufficient for everyone. The Unix Philosophy is a wonderful generalized solution, but it's well understood that a specialized solution CAN be more efficient, and provide additional usability and other benefits as well. Here, for instance, a specialized solution could work consistently across all of the possible supported mail store options, SIMULTANEOUSLY; whereas yours only works for a subset, and rather clunkily. Are you honestly telling me that if Mutt had a powerful cross-message-store search function that was integrated seamlessly with its UI, that you would still use grep instead? Cuz that sounds pretty crazy. -- Derek D. Martinhttp://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience. pgp2354_kHKZ4.pgp Description: PGP signature
Re: How do you survive without notmuch?
On 12.04.16 13:05, Derek Martin wrote: > On Tue, Apr 12, 2016 at 05:28:08PM +1000, Erik Christiansen wrote: > > The really big benefit of the Unix approach is that the same utility > > know-how can be applied to every problem, as it is only the mix of > > utilities used, and their parameters, which vary. > > The downside is that typical users don't want to learn all those > tools, and by and large have no reason to. They use the web and > e-mail, and very little else. Yes, what could be inferred from your first reply is now explicit. May your typicality serve you well, and the rest of us tolerate what the other has learned first and uses best. Erik -- The ultimate barrier is one's viewpoint. - Terry Pratchett, "The Dark Side of the Sun"
Re: How do you survive without notmuch?
On Tue, Apr 12, 2016 at 05:28:08PM +1000, Erik Christiansen wrote: > > But you must see the flaw with this approach: It requires every user > > to make efforts to integrate their own solution for searching for > > their mail > > Whether that's an attempt at humour, or just late for April 1, eludes > me. The flaw with the postulating paragraph is that there is no need > for integration of "own solution for searching". That is already > provided by Unix - for free, as is. Your solution is to use grep. How well does that work if your mail is stored on an imap server which you don't have shell access to, or in any sort of a server where the mail store is in a database which you again, do not have access to, even if you happen to have shell access to that machine? In this case, the ONLY place to put the search functionality is in the mail client. > Compatible cooperating utilities always beat competing and often > conflicting monoliths, in my several decades of experience. I think I just proved otherwise. The other benefit that a monolith can provide is consistency of interface. That reduces learning curve even further. Of course you can write a monolith that fails at this, but the point would be to NOT do that. ;-) > Your own words make that case for me. No monolith "is the right solution > for every problem." That does not prove your case; it does nothing to prove that a monolith is not better IN THIS SPECIFIC CASE. :) > The really big benefit of the Unix approach is that the same utility > know-how can be applied to every problem, as it is only the mix of > utilities used, and their parameters, which vary. The downside is that typical users don't want to learn all those tools, and by and large have no reason to. They use the web and e-mail, and very little else. All those Unix tools come into play exactly zero if their mail client already has reasonable search capabilities. This is fine for you and me; we have lots of reasons to know those tools. But we have had at least a few non-technical users asking questions about how to do things on mutt-users over the years, and I have to think there are more who don't post or even subscribe. Your solution forces those people to learn a pile of tools they likely otherwise have no use for. That's a monumental wasted effort, if you ask me. Frankly, I love Mutt, and I'm plenty technical; but I'd still prefer to see it become WAY easier to learn and use, even if I know how to dance around all the issues that it presents me by not solving them itself. -- Derek D. Martinhttp://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience. pgpMNk_pRNII2.pgp Description: PGP signature
Re: How do you survive without notmuch?
On 11.04.16 11:11, Derek Martin wrote: > On Mon, Apr 11, 2016 at 10:13:06PM +1000, Erik Christiansen wrote: > > In the latter half of several decades of software development, I took to > > heart "Unix _is_ the IDE". Similarly, there's no need for mutt to do > > more than be a good MUA, as perfectly good search capability pre-exists. > > But you must see the flaw with this approach: It requires every user > to make efforts to integrate their own solution for searching for > their mail--a task that seems (to me) very obviously part of what > any typical user would want to do, as part of handling their mail. As > such, doesn't it make sense that the MUA have good searching > capabilities built in? Doing so saves a MASSIVE amount of work, in > man-hours. Whether that's an attempt at humour, or just late for April 1, eludes me. The flaw with the postulating paragraph is that there is no need for integration of "own solution for searching". That is already provided by Unix - for free, as is. As a consequence, the theory that there might be "a MASSIVE amount of work" is purest fantasy. I have done _no_ substantial work, as 'perfectly good search capability pre-exists'. > This is where the Unix Philosophy falls down, IMO. And don't get me > wrong--I'm a fan. But no solution is the right solution for every > problem. Compatible cooperating utilities always beat competing and often conflicting monoliths, in my several decades of experience. The flexibility of combining coherent capabilities to construct an application-specific solution cannot be matched by a user-restricting monolith with a limited set of fixed actions. Your own words make that case for me. No monolith "is the right solution for every problem." That is why a swarm of well-understood smaller combinable utilities is always more flexible, and better able to handle a large variety of problems. The really big benefit of the Unix approach is that the same utility know-how can be applied to every problem, as it is only the mix of utilities used, and their parameters, which vary. With the monolithic approach, the user has to learn a different set of levers to wrangle for every monolith allowed on his system. That can be a massive amount of trial-and-error climbing of learning curve - a completely unnecessary waste of time. Erik -- The ultimate barrier is one's viewpoint. - Terry Pratchett, "The Dark Side of the Sun"
Re: How do you survive without notmuch?
On Mon, Apr 11, 2016 at 10:13:06PM +1000, Erik Christiansen wrote: > In the latter half of several decades of software development, I took to > heart "Unix _is_ the IDE". Similarly, there's no need for mutt to do > more than be a good MUA, as perfectly good search capability pre-exists. But you must see the flaw with this approach: It requires every user to make efforts to integrate their own solution for searching for their mail--a task that seems (to me) very obviously part of what any typical user would want to do, as part of handling their mail. As such, doesn't it make sense that the MUA have good searching capabilities built in? Doing so saves a MASSIVE amount of work, in man-hours. This is where the Unix Philosophy falls down, IMO. And don't get me wrong--I'm a fan. But no solution is the right solution for every problem. -- Derek D. Martinhttp://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience. pgpPyRka07mij.pgp Description: PGP signature
Re: How do you survive without notmuch?
On 05.04.16 12:47, Xu Wang wrote: > I am so used to using notmuch integrated into mutt (via mutt-kz), that > I would like to be able to understand how someone does *not* use > notmuch. How do you search for a certain message? Is it simply a > matter of the following? Deleting around 90% of list traffic makes searching faster. Organising what is retained, according to subject is an even greater accelerator: $ ls -1 mail/* | wc -l 1211 On the rare occasions I'm not sure where to look, grep always quickly delivers the goods for me. It's generally not necessary to search all 1211 mailboxes, e.g. $ grep foo mail/mutt_* > /tmp/matches Opening /tmp/matches with vim, I can then use gf on likely candidates. In more than a decade of this efficient practice, I've had not much reason to seek any alternative. Just once it seemed to fail, until I broadened a limited search, as above, to scan all files. I had archived the post under a more relevant topic. A simple but useful aid has been the shell function: mls () { ls -xF ~/mail/*$1* } Now any part of a subject name finds all related collections: $ mls security /home/erik/mail/cnc_linux_security/home/erik/mail/linux_security /home/erik/mail/linux_security_hints /home/erik/mail/postfix_security /home/erik/mail/ubuntu_security In the latter half of several decades of software development, I took to heart "Unix _is_ the IDE". Similarly, there's no need for mutt to do more than be a good MUA, as perfectly good search capability pre-exists. (For slightly faster searches, fgrep, and for modern regex, egrep.) Erik
Re: How do you survive without notmuch?
On 09Apr2016 13:49, suvayu aliwrote: On Thu, Apr 07, 2016 at 10:50:13PM +0200, bastian-muttu...@t6l.de wrote: On 07Apr16 19:53 +0200, Andreas wrote: > Me too and while it does find the message it does not tell me /where/ it > is. How do you do this? I do not precisely know about notmuch, but the indexers I know about they create links to the original mail in a temporary maildir folder. At least follow those links. Notmuch uses a Xapian database, so no links. Here's one way to find the actual file: $ notmuch search --output=files -- id:20160407205013.gd25...@tweddell.de /home/user/Mail/Gmail/mutt/cur/1460064940_0.8667.hostname,U=5543,FMD5=85a057cb845658bd35be5e2458429a42:2,S Indeed. My "notmuch-search" script (which I invoke via a convenience alias) has this logic at the bottom: if [ $dothreads ] then notmuch search --output=threads -- "$@" \ | while read -r tid do notmuch search --output=files -- "$tid" done else notmuch search --output=files -- "$@" fi \ | egrep '/(new|cur)/[^/]+$' \ which pipes to something which symlinks the message filenames into a maildir, so I end up with a search result maildir full of symlinks to the originals. In principle I could inspect it. Cheers, Cameron Simpson
Re: How do you survive without notmuch?
On Thu, Apr 07, 2016 at 10:50:13PM +0200, bastian-muttu...@t6l.de wrote: > On 07Apr16 19:53 +0200, Andreas wrote: > > > Me too and while it does find the message it does not tell me /where/ it > > is. How do you do this? > > I do not precisely know about notmuch, but the indexers I know about > they create links to the original mail in a temporary maildir folder. At > least follow those links. Notmuch uses a Xapian database, so no links. Here's one way to find the actual file: $ notmuch search --output=files -- id:20160407205013.gd25...@tweddell.de /home/user/Mail/Gmail/mutt/cur/1460064940_0.8667.hostname,U=5543,FMD5=85a057cb845658bd35be5e2458429a42:2,S Cheers, -- Suvayu Open source is the future. It sets us free.
Re: How do you survive without notmuch?
On Thu, Apr 07, 2016 at 07:10:12PM -0500, Luis Mochan wrote: > On Thu, Apr 07, 2016 at 10:50:13PM +0200, bastian-muttu...@t6l.de wrote: > > On 07Apr16 19:53 +0200, Andreas wrote: > > > Am 07.04.2016 um 01:19 schrieb Cameron Simpson: > > ... > > By now I cannot imagine any solution which is more flexible (for me). > > Comments welcome! > I do basically the same, with some scripts to add Xlabels to > individual messages, instead of saving them in different > mailboxes/maildirs. > > > Me too and while it does find the message it does not tell me /where/ it > > > is. How do you do this? > > > > I do not precisely know about notmuch, but the indexers I know about > > they create links to the original mail in a temporary maildir folder. At > > least follow those links. > > Actually, to find the location of a mail file grepmail is a nice tool, > > which I used long time ago. > > I use maidir-utils. mu find can show you the actual location of a > message if you use the option --fields "... l" as in > > mu find from:somefriend tag:somelabel --fields "d f s l" > > which prints date, from, subject and location for each matching message. Back then I compared mairix with notmuch and selected the latter for reasons I cannot recall any more. As stated in another post mairix would already return the location in the header. I am going to reevaluate my decision taking maildir-utils into account as a third possibilty. > Regards, > Luis Regards Andreas
Re: How do you survive without notmuch?
On Thu, Apr 07, 2016 at 07:53:48PM +0200, Andreas wrote: > > Usually when I reach for notmuch it is because I have mismanaged my > > folders. Hmm, that message about blah isn't there - where is it? > > Me too and while it does find the message it does not tell me /where/ it > is. How do you do this? muttjump [1] claims to be able to solve this problem but I did not tested it. I'm usually totally fine with the feature of getting the whole thread of a message (-r thread parameter for notmuch-mutti [2]) macro index,pager ,t \ "set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key\ notmuch-mutt -r thread\ `echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`\ set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key" \ "notmuch: reconstruct thread" Best regards Sebastian Tramp 1. https://github.com/weisslj/muttjump 2. https://notmuchmail.org/notmuch-mutt/ -- WebID: http://sebastian.tramp.name
Re: How do you survive without notmuch?
On Thu, Apr 07, 2016 at 10:50:13PM +0200, bastian-muttu...@t6l.de wrote: > On 07Apr16 19:53 +0200, Andreas wrote: > > Am 07.04.2016 um 01:19 schrieb Cameron Simpson: > > > Usually when I reach for notmuch it is because I have mismanaged my > > > folders. Hmm, that message about blah isn't there - where is it? > > Here, just a quick glimpse into my experience. > I discovered an easy way of life, at the time I stopped to sort my mails > into folders - either manually or automatically. For me it was just one > big source of failures. Mails could sometimes be sorted into multiple > folders, so where should I look to find that one again? And what the > heck is the sent-folder for? It just rips threads apart. > > This made me change completely my email administration approx a decade > ago. Now, I just use two maildirs. inbox and trash. Where trash is more > the entire mail history and inbox a kind of todo or active threads. > Mails I sent are also put into inbox, thus I can follow threaded > discussions much better. [..] > By now I cannot imagine any solution which is more flexible (for me). > Comments welcome! That reminds me of https://gtdfh.branchable.com/ -- The media's the most powerful entity on earth. They have the power to make the innocent guilty and to make the guilty innocent, and that's power. -- Malcolm X
portable shell scripts (was Re: How do you survive without notmuch?)
On Thu, Apr 07, 2016 at 10:21:24PM -0400, Jon LaBadie wrote: > For several years starting in '83 the group I worked with authored > some of the AT courses on shell programming. This was one defect > that we reported in the Bourne shell, but not the Korn shell courses. So when is the first meeting of The Old Men's Nostalgic Shell Scripting Club? Or does this thread count as that? =8^) -- Derek D. Martinhttp://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience. pgp25poLTSAEA.pgp Description: PGP signature
Re: portable shell scripts (was: How do you survive without notmuch?)
On 07Apr2016 22:27, derek martinwrote: On Thu, Apr 07, 2016 at 04:23:18PM -0700, David Champion wrote: Speaking of which, it's taken me until the last year to use $(command) consistently instead of `command`, and I'm not sure anymore why I was a stickler. I assume some older shell didn't support $() but I can't recall which. I still don't, as you may have noticed above. ;-) But I DO use it, and notably you can combine `` and $() to get two levels of execution. That's occasionally handy. I started getting aggressive about $() in the last year or so; it has certainly been around for long enough. The big attraction for me is that it nests without introducing more slosh-escaping levels. So you can $( ... $( ... $(...) ... ) ... ) without stuff getting nasty. Not that I nest that deeply, but whenever I have a regexp or the like inside `` it is immediately more painful. Cheers, Cameron Simpson
Re: portable shell scripts (was: How do you survive without notmuch?)
On Fri, Apr 08, 2016 at 08:51:52AM +1000, Cameron Simpson wrote: > On 07Apr2016 10:37, derek martinwrote: > >I've yet to notice any of the so-called benefits of getting older, > >that people sometimes extoll... > > My father once asserted that it was better than the alternative. Fair point! On rare occasions though, I'm not so sure... > Oh, please digress! > > I tend to use printf over echo for when I want well controlled > output; the BSD/SysV echo stuff has been a pain point for decades so > I try to just avoid it when I'm outputting an "unknown" string. I've only taken to using printf lately in shell scripts, mostly for the likes of: i=0; while [ $i -lt $limit ]; do filename=`printf "file%04d" $i` # do something with file0xxx ... > What other scripting shortcomings have you encountered with dash? I > haven't used it much myself, but would hope to have my scripts > portable enough to work with it. Honestly I can't recall... It's been a few years since I used shell scripts for much more than stringing together a bunch of other programs I've written or short one-offs. One thing is I have a handful of scripts I use a lot that make use of bash arrays to convert numeric input into strings to be used in SQL queries. Bash is hardly the only shell that provides arrays... I want them in shells I use for scripting, and frankly I want to use /bin/sh (or at least a shell that behaves exactly like I expect /bin/sh to behave)... I specifically DO NOT want to use /bin/bash in my shell scripts, because this changes various behaviors of the shell, including causing it to read certain of your shell startup files when your script starts (yes, even in non-interactive shells), which is not what you want if you're running shell scripts. Honestly, what I really want is for the distros to return bash to /bin/sh, configure the kernel and any relevant startup scripts to use dash directly if that's what they want to use to start the system up, and maybe consider statically linking /bin/bash so that it doesn't break if shared libs are missing (which it may already be, I'm too lazy to open a window to check). =8^) On Thu, Apr 07, 2016 at 04:23:18PM -0700, David Champion wrote: > Speaking of which, it's taken me until the last year to use $(command) > consistently instead of `command`, and I'm not sure anymore why I was > a stickler. I assume some older shell didn't support $() but I can't > recall which. I still don't, as you may have noticed above. ;-) But I DO use it, and notably you can combine `` and $() to get two levels of execution. That's occasionally handy. -- Derek D. Martinhttp://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience. pgpyURJxa9152.pgp Description: PGP signature
Re: How do you survive without notmuch?
On Wed, Apr 06, 2016 at 07:52:00PM -0400, Ben Boeckel wrote: > On Thu, Apr 07, 2016 at 09:38:43 +1000, Cameron Simpson wrote: > > For historic reasons, "$@" evaluates to a single "" if there were no > > arguments > > at all, introducing a spurious new empty argument. Possibly the thinking > > was > > that something like "$@" should never vanish; after all "$x" will produce > > an > > single empty string if $x is empty. The ${1+} simply avoids using "$@" at > > all > > unless there are arguments, producing correct behaviour in the no-arguments > > case. > > What shell is that? I've *never* encountered such a bug (well, I'd classify it > as such at this point) and I do quite a bit of shell scripting. > For several years starting in '83 the group I worked with authored some of the AT courses on shell programming. This was one defect that we reported in the Bourne shell, but not the Korn shell courses. With each new OS release or hardware variant, we had a set of about four oddities to check. We felt this one was a bug but while I was there it was not fixed. Others were poorly defined things that varied from release to release or among hardware variants. If I remember correctly, the "$@" bug was not fixed in the original System V release and possibly even SVR2. I'm sure it was fixed by the great merger, SVR4. jl -- Jon H. LaBadie j...@jgcomp.com 11226 South Shore Rd. (703) 787-0688 (H) Reston, VA 20190 (703) 935-6720 (C)
Re: How do you survive without notmuch?
* Cameron Simpson[04-07-16 18:59]: > On 07Apr2016 19:53, Andreas wrote: > >Am 07.04.2016 um 01:19 schrieb Cameron Simpson: > >>Usually when I reach for notmuch it is because I have mismanaged my > >>folders. Hmm, that message about blah isn't there - where is it? > > > >Me too and while it does find the message it does not tell me /where/ it > >is. How do you do this? > > Fair question. No idea. I cheat and copy the found message to where I > expected it to be, if I feel the need. > > If notmuch makes symlinks in its results folder (haven't checked) one could > examine the symlink. If hard links, it is a little trickier, requiring a > find using the inode number I suppose. Does notmuch have a reporting mode > ("where are the messages" rather than "here are the messages")? One place where mairix appeals besides accepting mbox, it adds a header to the found email showing it's location. -- (paka)Patrick Shanahan Plainfield, Indiana, USA @ptilopteri http://en.opensuse.orgopenSUSE Community Memberfacebook/ptilopteri http://wahoo.no-ip.orgPhoto Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535@ http://linuxcounter.net
Re: How do you survive without notmuch?
On Thu, Apr 07, 2016 at 10:50:13PM +0200, bastian-muttu...@t6l.de wrote: > On 07Apr16 19:53 +0200, Andreas wrote: > > Am 07.04.2016 um 01:19 schrieb Cameron Simpson: > ... > By now I cannot imagine any solution which is more flexible (for me). > Comments welcome! I do basically the same, with some scripts to add Xlabels to individual messages, instead of saving them in different mailboxes/maildirs. > > Me too and while it does find the message it does not tell me /where/ it > > is. How do you do this? > > I do not precisely know about notmuch, but the indexers I know about > they create links to the original mail in a temporary maildir folder. At > least follow those links. > Actually, to find the location of a mail file grepmail is a nice tool, > which I used long time ago. I use maidir-utils. mu find can show you the actual location of a message if you use the option --fields "... l" as in mu find from:somefriend tag:somelabel --fields "d f s l" which prints date, from, subject and location for each matching message. Regards, Luis
Re: How do you survive without notmuch?
On Thu, Apr 07, 2016 at 08:10:13PM -0400, Fred Smith wrote: > > well, to answer the OP, I've never before heard of notmuch, so I've > never missed it! At least notmuch w
Re: How do you survive without notmuch?
On Fri, Apr 08, 2016 at 08:56:33AM +1000, Cameron Simpson wrote: > On 07Apr2016 19:53, Andreaswrote: > >Am 07.04.2016 um 01:19 schrieb Cameron Simpson: > >>Usually when I reach for notmuch it is because I have mismanaged my > >>folders. Hmm, that message about blah isn't there - where is it? > > > >Me too and while it does find the message it does not tell me /where/ it > >is. How do you do this? > > Fair question. No idea. I cheat and copy the found message to where > I expected it to be, if I feel the need. > > If notmuch makes symlinks in its results folder (haven't checked) > one could examine the symlink. If hard links, it is a little > trickier, requiring a find using the inode number I suppose. Does > notmuch have a reporting mode ("where are the messages" rather than > "here are the messages")? > > Anyone? > > Cheers, > Cameron Simpson well, to answer the OP, I've never before heard of notmuch, so I've never missed it! -- Fred Smith -- fre...@fcshome.stoneham.ma.us - "And he will be called Wonderful Counselor, Mighty God, Everlasting Father, Prince of Peace. Of the increase of his government there will be no end. He will reign on David's throne and over his kingdom, establishing and upholding it with justice and righteousness from that time on and forever." --- Isaiah 9:7 (niv) --
Re: portable shell scripts (was: How do you survive without notmuch?)
What fun! * On 07 Apr 2016, Cameron Simpson wrote: > > Ah. I like zsh for my interactive shell. But we always leave root's shell > alone. However, I am a _very_ strong advocate for writing scripts for > /bin/sh, and avoiding bashisms for exactly your reasons above. Am I alone in > wincing everytime I hear the term "bash scripting" these days? No, you're not. :) I haven't brought myself to use zsh yet, because I do a lot of /bin/sh snippet teseting in my interactive shell and I like it to interpret bourne code correctly. Bash does, but zsh does not -- even with all the compatibility options set. There are certain bourne sequences that zsh does the wrong thing with, and that affects my scripting. > > Though, the > > switch in many Linux distros to dash as the system shell has somewhat > > thwarted me--dash isn't (IMO) usable as an interactive shell, has some > > issues as a scripting shell, and has slightly different semantics (BSD > > vs. SysV echo, for instance) than bash on some oft-used builtins, > > etc.. I find this extremely annoying. I get why they did it, but I > > think it would have been a much better idea to produce a > > bash-workalike shell for the subset of features they wanted to > > support. Or patch dash to behave the same where its supported > > features differ. Anyway, I digress. > > Oh, please digress! I tend to like dash, although my experience of it is limited. I didn't like ash but dash seems pretty solid so far. And its code is quite readable. This is excellent. Bash is a morass. > but printf for parameterised output: > > printf '%s\n' "$arbitrary_value" I've started leaning on printf for newline-less printing lately -- it's just easier. But you must be careful to use 'printf %s "$foo"' instead of just 'printf $foo', since otherwise a % in input can thwart. > and I have my own script "necho" for "echo with no newline" for the > appropriat platform (or I make a shell function necho() calling printf for > the same purpose, depending on context). Then one can go: Let's see if I can get this right from memory: case "`echo -n`" in) -n) necho () { echo "$@""\c"; };; *) necho () { echo -n "$@"; };; esac Speaking of which, it's taken me until the last year to use $(command) consistently instead of `command`, and I'm not sure anymore why I was a stickler. I assume some older shell didn't support $() but I can't recall which. -- David Champion • d...@bikeshed.us
portable shell scripts (was: How do you survive without notmuch?)
On 07Apr2016 10:37, derek martinwrote: I've yet to notice any of the so-called benefits of getting older, that people sometimes extoll... My father once asserted that it was better than the alternative. Probably fixed in modern interactive shells. Note your test is testing your interactive shell, not /bin/sh (if they're different). On the system I ran the test on, they happen to be the same. On other systems I use /bin/sh is dash, but I believe it behaves the same. My sysadmin background has led me to think that you should always just use the system default shell, because it's pretty much always going to be available unless the system is completely unusable, and because perhaps there's a good reason it's the default. ;-) Ah. I like zsh for my interactive shell. But we always leave root's shell alone. However, I am a _very_ strong advocate for writing scripts for /bin/sh, and avoiding bashisms for exactly your reasons above. Am I alone in wincing everytime I hear the term "bash scripting" these days? Though, the switch in many Linux distros to dash as the system shell has somewhat thwarted me--dash isn't (IMO) usable as an interactive shell, has some issues as a scripting shell, and has slightly different semantics (BSD vs. SysV echo, for instance) than bash on some oft-used builtins, etc.. I find this extremely annoying. I get why they did it, but I think it would have been a much better idea to produce a bash-workalike shell for the subset of features they wanted to support. Or patch dash to behave the same where its supported features differ. Anyway, I digress. Oh, please digress! I tend to use printf over echo for when I want well controlled output; the BSD/SysV echo stuff has been a pain point for decades so I try to just avoid it when I'm outputting an "unknown" string. So I use echo for all the fixed stuff: echo "message here, with no leading dashes or backslashes in the text" but printf for parameterised output: printf '%s\n' "$arbitrary_value" and I have my own script "necho" for "echo with no newline" for the appropriat platform (or I make a shell function necho() calling printf for the same purpose, depending on context). Then one can go: necho "prompt> " in one's script without worrying too much or making the script harder to read. What other scripting shortcomings have you encountered with dash? I haven't used it much myself, but would hope to have my scripts portable enough to work with it. Cheers, Cameron Simpson
Re: How do you survive without notmuch?
On 07Apr2016 19:53, Andreaswrote: Am 07.04.2016 um 01:19 schrieb Cameron Simpson: Usually when I reach for notmuch it is because I have mismanaged my folders. Hmm, that message about blah isn't there - where is it? Me too and while it does find the message it does not tell me /where/ it is. How do you do this? Fair question. No idea. I cheat and copy the found message to where I expected it to be, if I feel the need. If notmuch makes symlinks in its results folder (haven't checked) one could examine the symlink. If hard links, it is a little trickier, requiring a find using the inode number I suppose. Does notmuch have a reporting mode ("where are the messages" rather than "here are the messages")? Anyone? Cheers, Cameron Simpson
Re: How do you survive without notmuch?
On 07Apr16 19:53 +0200, Andreas wrote: > Am 07.04.2016 um 01:19 schrieb Cameron Simpson: > > Usually when I reach for notmuch it is because I have mismanaged my > > folders. Hmm, that message about blah isn't there - where is it? Here, just a quick glimpse into my experience. I discovered an easy way of life, at the time I stopped to sort my mails into folders - either manually or automatically. For me it was just one big source of failures. Mails could sometimes be sorted into multiple folders, so where should I look to find that one again? And what the heck is the sent-folder for? It just rips threads apart. This made me change completely my email administration approx a decade ago. Now, I just use two maildirs. inbox and trash. Where trash is more the entire mail history and inbox a kind of todo or active threads. Mails I sent are also put into inbox, thus I can follow threaded discussions much better. To find emails by searching, I begun to use mutt's powerfull limit functionality on the trash. This became quite slow by time and growing mbox. Afer changing to maildir, I also got interested in mail indexers (started with mairix, now maildir-utils) which let me easily and dynamically switch to the context I desire. In addition to that, since using maildir-utils, I use `mu cfind` as my email address book via query_command. So there is no need to add mailaddresses to the alias file any more. By now I cannot imagine any solution which is more flexible (for me). Comments welcome! > Me too and while it does find the message it does not tell me /where/ it > is. How do you do this? I do not precisely know about notmuch, but the indexers I know about they create links to the original mail in a temporary maildir folder. At least follow those links. Actually, to find the location of a mail file grepmail is a nice tool, which I used long time ago. Cheers, -- Bastian
Re: How do you survive without notmuch?
* On 07 Apr 2016, Christian Brabandt wrote: > > According to Sven Maschecks website > http://www.in-ulm.de/~mascheck/various/bourne_args/ > > , > | These shells behave the old way and need ${1+"$@"}: > | > | Certainly: /bin/sh on 7th edition (aka Version 7). And thus also /bin/sh on > original BSDs, until these shipped the Almquist shell (after 4.3BSD-Reno) > | HP-UX 8, 9 /bin/sh, HP-UX 10.x, 11.x /usr/old/bin/sh (as /bin/sh has become > a ksh) > | OSF1/V4 and V5 aka Tru64 /bin/sh > | Ultrix /bin/sh and /bin/sh5 > | Sinix 5.20 /bin/sh in both the "ucb" and the "sie" universe > ` Thanks, that must be it. Not Solaris and IRIX, but HP-UX and OSF/1. BTW OSF/1 refers to v1-v3. v3.2-v4 are Digital Unix or, later (v4.0F), Tru64. > so basically, not relevant anymore. Some people still have to support some of those, believe it or not. Related: if [ x = "x$1" ] ... -- David Champion • d...@bikeshed.us
Re: How do you survive without notmuch?
On Mi, 06 Apr 2016, Ben Boeckel wrote: > On Thu, Apr 07, 2016 at 09:38:43 +1000, Cameron Simpson wrote: > > For historic reasons, "$@" evaluates to a single "" if there were no > > arguments at all, introducing a spurious new empty argument. > > Possibly the thinking was that something like "$@" should never > > vanish; after all "$x" will produce an single empty string if $x is > > empty. The ${1+} simply avoids using "$@" at all unless there are > > arguments, producing correct behaviour in the no-arguments case. > > What shell is that? I've *never* encountered such a bug (well, I'd > classify it as such at this point) and I do quite a bit of shell > scripting. According to Sven Maschecks website http://www.in-ulm.de/~mascheck/various/bourne_args/ , | These shells behave the old way and need ${1+"$@"}: | | Certainly: /bin/sh on 7th edition (aka Version 7). And thus also /bin/sh on original BSDs, until these shipped the Almquist shell (after 4.3BSD-Reno) | HP-UX 8, 9 /bin/sh, HP-UX 10.x, 11.x /usr/old/bin/sh (as /bin/sh has become a ksh) | OSF1/V4 and V5 aka Tru64 /bin/sh | Ultrix /bin/sh and /bin/sh5 | Sinix 5.20 /bin/sh in both the "ucb" and the "sie" universe ` so basically, not relevant anymore. regards, Christian -- The Martian landed his saucer in Manhattan, and immediately upon emerging was approached by a panhandler. "Mister," said the man, "can I have a quarter?" The Martian asked, "What's a quarter?" The panhandler thought a minute, brightened, then said, "You're right! Can I have a dollar?"
Re: How do you survive without notmuch?
* On 06 Apr 2016, Cameron Simpson wrote: > On 06Apr2016 19:52, Ben Boeckelwrote: > > On Thu, Apr 07, 2016 at 09:38:43 +1000, Cameron Simpson wrote: > > > For historic reasons, "$@" evaluates to a single "" if there were no > > > arguments > > > at all, introducing a spurious new empty argument. Possibly the thinking > > > was > > > > What shell is that? I've *never* encountered such a bug (well, I'd classify > > it > > as such at this point) and I do quite a bit of shell scripting. > > Probably fixed in modern shells. How long have you been shell scripting? (I > also consider it a bug; the incantation is a workaround.) I vouch for this. I've encountered it in practice, although I couldn't presently say where or when. And I used the same solution, and I still write it if I want to be especially robust. I don't like to assume my code will never be run on an older machine, especially when I have a amiga running netbsd 1.0 and a next slab in the basement. (I recently got rid of all my other suns, sgis, and alphas. I used to be able to make a stronger case.) I'm not completely sure, but I *think* that I still saw this behavior on late-model bourne shells (i.e. not bash or zsh) derived from svr5 code the last time I used solaris or irix. But while it's probably a bug, it's the kind of bug that becomes entrenched and is actually dangerous to fix when a decent workaround is available. I think the architects of modernity made a mistake on this one -- although reverting it now would be a mistake for the same reason. -- David Champion • d...@bikeshed.us
Re: How do you survive without notmuch?
Am 07.04.2016 um 01:19 schrieb Cameron Simpson: [...] Hi all > Usually when I reach for notmuch it is because I have mismanaged my > folders. Hmm, that message about blah isn't there - where is it? Me too and while it does find the message it does not tell me /where/ it is. How do you do this? > > Cheers, > Cameron Simpson> Regards Andreas
Re: How do you survive without notmuch?
On Thu, Apr 07, 2016 at 11:49:05AM +1000, Cameron Simpson wrote: > On 06Apr2016 19:33, derek martinwrote: > >Then again, maybe I did know that once--my > >memory chips have become increasingly faulty with age. ;-) > > Me too. I am further hampered by little "calendar" time sense; other > people can say "oh this happened in 2001", I have no idea and have > to reference wrt to specific events in my memory, hoping they have > dates associated. I've yet to notice any of the so-called benefits of getting older, that people sometimes extoll... > Probably fixed in modern interactive shells. Note your test is > testing your interactive shell, not /bin/sh (if they're different). On the system I ran the test on, they happen to be the same. On other systems I use /bin/sh is dash, but I believe it behaves the same. My sysadmin background has led me to think that you should always just use the system default shell, because it's pretty much always going to be available unless the system is completely unusable, and because perhaps there's a good reason it's the default. ;-) Though, the switch in many Linux distros to dash as the system shell has somewhat thwarted me--dash isn't (IMO) usable as an interactive shell, has some issues as a scripting shell, and has slightly different semantics (BSD vs. SysV echo, for instance) than bash on some oft-used builtins, etc.. I find this extremely annoying. I get why they did it, but I think it would have been a much better idea to produce a bash-workalike shell for the subset of features they wanted to support. Or patch dash to behave the same where its supported features differ. Anyway, I digress. FWIW I haven't been at it quite as long as you, evidently, but I've been writing shell scripts for about 25 years on maybe 8 different platforms, and I've never encountered the bug you describe... I didn't know about (or remember) the ${x:+y} syntax though, so just goes to show there's always something to (re)learn, no matter how long you've been at it. =8^) -- Derek D. Martinhttp://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience. pgpXGaikiPSHQ.pgp Description: PGP signature
Re: How do you survive without notmuch?
On Thu, Apr 07, 2016 at 11:55:10 +1000, Cameron Simpson wrote: > Probably fixed in modern shells. How long have you been shell scripting? (I > also consider it a bug; the incantation is a workaround.) I first landed in *nix land with Fedora Core 5 (2005 or 2006, I forget which), was doing shell not too long after that (though I also graduated high school a few years later, so it isn't *that* late given my age and computer access history; overall, yeah). I am strict with my shell code though (POSIX where possible and littered with things like 'readonly' and 'local' to keep things safer). More surprised that the bugs from long ago *weren't* kept in the name of compatibility. > Not claiming it is necessary today, but it is like proving the nonexistence > of > things - not possible in general. It definitely was necessary in the past. Indeed. I think there's an SGI around at work that I might be able to test… Seems that SunOS 5.10 is also OK (including sh, bash, ksh, jsh, pfsh, and tcsh) is also OK with it. > Derek did a similar test. Looks like most modern systems behave well. But the > day I run up a PDP-11 in a VM :) --Ben
Re: How do you survive without notmuch?
On 06Apr2016 19:52, Ben Boeckelwrote: On Thu, Apr 07, 2016 at 09:38:43 +1000, Cameron Simpson wrote: For historic reasons, "$@" evaluates to a single "" if there were no arguments at all, introducing a spurious new empty argument. Possibly the thinking was that something like "$@" should never vanish; after all "$x" will produce an single empty string if $x is empty. The ${1+} simply avoids using "$@" at all unless there are arguments, producing correct behaviour in the no-arguments case. What shell is that? I've *never* encountered such a bug (well, I'd classify it as such at this point) and I do quite a bit of shell scripting. Probably fixed in modern shells. How long have you been shell scripting? (I also consider it a bug; the incantation is a workaround.) Not claiming it is necessary today, but it is like proving the nonexistence of things - not possible in general. It definitely was necessary in the past. Derek did a similar test. Looks like most modern systems behave well. But the day I run up a PDP-11 in a VM Cheers, Cameron Simpson
Re: How do you survive without notmuch?
On 06Apr2016 18:53, Jon LaBadiewrote: In the distant past constructions like that were needed because of a bug in the shells. If you had no arguments, "$@" was passed as "", a single null argument. Now it is correctly passed as no arguments. OT BTW I typically used ${@+"$@"} and playing with it after seeing this thread discovered a bug in handling it in ksh but not bash or zsh. Ksh only checks $1 for set/null rather than the entire list of args. Got some demo code? The construction only tests $1 for set/null anyway, on the premise that that tests entire-list-of-args is empty/not-empty. I don't think I understand your sentence. Thanks, Cameron Simpson
Re: How do you survive without notmuch?
On 06Apr2016 19:33, derek martinwrote: On Thu, Apr 07, 2016 at 09:38:43AM +1000, Cameron Simpson wrote: > if $1 is set use that, otherwise use "$@" (all arguments, individually quoted) No, it says ``if $1 is set, use "$@", otherwise use nothing''. See below. I see. So I had it exactly backwards. :) I often have to look these up too. I mostly use :- and := myself, aside from this special incantation. Firstly, "$@" _is_ portable; it has been around as a very special case for decades, since at least V7 UNIX. For sure. It was the ${keword+expression} syntax I was referring to. I didn't remember coming across this syntax until I started using HP-UX 10.0 with "the POSIX shell" so I assumed it was not portable, but it seems that it is. I've been using this incantation since the mid-80s, on systems older than that, so the basic kw+expr is plenty old. The newer pattern matching things are much younger, and IIRC only in bash and zsh and similar, not core Bourne shell. Then again, maybe I did know that once--my memory chips have become increasingly faulty with age. ;-) Me too. I am further hampered by little "calendar" time sense; other people can say "oh this happened in 2001", I have no idea and have to reference wrt to specific events in my memory, hoping they have dates associated. For historic reasons, "$@" evaluates to a single "" if there were no arguments at all, introducing a spurious new empty argument. Hmmm... This is news to me, and my quick test does not bear it out: Probably fixed in modern interactive shells. Note your test is testing your interactive shell, not /bin/sh (if they're different). $ cat foo.sh #!/bin/sh echo "$# command line args" $ ./foo.sh "$@" 0 command line args $ ./foo.sh "" 1 command line args -=-=-=- $ cat foo.c #include int main(int argc, char **argv) { printf("got %d command line args\n", argc - 1); return 0; } $ ./foo got 0 command line args $ ./foo "$@" got 0 command line args $ ./foo "" got 1 command line args Both script and C program are testing your interactive shell (bash? mine is usually zsh). BTW, you might repeat the test with a bare $@ as well. May be informative. I believe it should work like "$@", versus $* which works like normal variables. In any event, it appears that your paranoid version at the least does no harm. :) True, which is why my fingers continue to know it:-) Cheers, Cameron Simpson
Re: How do you survive without notmuch?
On Thu, Apr 07, 2016 at 09:38:43AM +1000, Cameron Simpson wrote: > > if $1 is set use that, otherwise use "$@" (all arguments, individually > > quoted) > > No, it says ``if $1 is set, use "$@", otherwise use nothing''. See below. I see. So I had it exactly backwards. :) > >It seems as though this always evaluates to $1 (since if $1 is unset, > >$@ is also necessarily empty)... which I think is not what is needed > >here. Am I mistaken? I believe just "$@" (including the quotes) is > >what you want here. > > Alas, no. And also no. > > Firstly, "$@" _is_ portable; it has been around as a very special > case for decades, since at least V7 UNIX. For sure. It was the ${keword+expression} syntax I was referring to. I didn't remember coming across this syntax until I started using HP-UX 10.0 with "the POSIX shell" so I assumed it was not portable, but it seems that it is. Then again, maybe I did know that once--my memory chips have become increasingly faulty with age. ;-) > For historic reasons, "$@" evaluates to a single "" if there were no > arguments at all, introducing a spurious new empty argument. Hmmm... This is news to me, and my quick test does not bear it out: $ cat foo.sh #!/bin/sh echo "$# command line args" $ ./foo.sh "$@" 0 command line args $ ./foo.sh "" 1 command line args -=-=-=- $ cat foo.c #include int main(int argc, char **argv) { printf("got %d command line args\n", argc - 1); return 0; } $ ./foo got 0 command line args $ ./foo "$@" got 0 command line args $ ./foo "" got 1 command line args In any event, it appears that your paranoid version at the least does no harm. :) -- Derek D. Martinhttp://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience. pgpx1e6Z9N1Af.pgp Description: PGP signature
Re: How do you survive without notmuch?
On Wed, Apr 06, 2016 at 04:26:52PM -0500, Derek Martin wrote: > Hi Cameron, > > On Wed, Apr 06, 2016 at 09:50:28AM +1000, Cameron Simpson wrote: > > Consider using ${1+"$@"}, which preserves quoting. > > How is this better than just "$@"? I believe it's non-portable (and > for that reason I'm less familiar with that syntax) but if I > understand correctly it expands like: > > if $1 is set use that, otherwise use "$@" (all arguments, individually > quoted) > > It seems as though this always evaluates to $1 (since if $1 is unset, > $@ is also necessarily empty)... which I think is not what is needed > here. Am I mistaken? I believe just "$@" (including the quotes) is > what you want here. In the distant past constructions like that were needed because of a bug in the shells. If you had no arguments, "$@" was passed as "", a single null argument. Now it is correctly passed as no arguments. OT BTW I typically used ${@+"$@"} and playing with it after seeing this thread discovered a bug in handling it in ksh but not bash or zsh. Ksh only checks $1 for set/null rather than the entire list of args. jl -- Jon H. LaBadie j...@jgcomp.com 11226 South Shore Rd. (703) 787-0688 (H) Reston, VA 20190 (703) 935-6720 (C)
Re: How do you survive without notmuch?
On Thu, Apr 07, 2016 at 09:38:43 +1000, Cameron Simpson wrote: > For historic reasons, "$@" evaluates to a single "" if there were no > arguments > at all, introducing a spurious new empty argument. Possibly the thinking was > that something like "$@" should never vanish; after all "$x" will produce an > single empty string if $x is empty. The ${1+} simply avoids using "$@" at all > unless there are arguments, producing correct behaviour in the no-arguments > case. What shell is that? I've *never* encountered such a bug (well, I'd classify it as such at this point) and I do quite a bit of shell scripting. % cat argc.c int main(int argc, char* argv[]) { return argc; } % gcc argc.c % cat foo.sh #!/bin/sh exec ./a.out "$@" % sh foo.sh; echo $? 1 % bash foo.sh; echo $? 1 % bash --posix foo.sh; echo $? 1 % zsh foo.sh; echo $? 1 % sh foo.sh ""; echo $? 2 % bash foo.sh ""; echo $? 2 % bash --posix foo.sh ""; echo $? 2 % zsh foo.sh ""; echo $? 2 --Ben
Re: How do you survive without notmuch?
On 06Apr2016 16:26, derek martinwrote: Hi Cameron, On Wed, Apr 06, 2016 at 09:50:28AM +1000, Cameron Simpson wrote: Consider using ${1+"$@"}, which preserves quoting. How is this better than just "$@"? I believe it's non-portable (and for that reason I'm less familiar with that syntax) but if I understand correctly it expands like: if $1 is set use that, otherwise use "$@" (all arguments, individually quoted) No, it says ``if $1 is set, use "$@", otherwise use nothing''. See below. It seems as though this always evaluates to $1 (since if $1 is unset, $@ is also necessarily empty)... which I think is not what is needed here. Am I mistaken? I believe just "$@" (including the quotes) is what you want here. Alas, no. And also no. Firstly, "$@" _is_ portable; it has been around as a very special case for decades, since at least V7 UNIX. For those unfamiliar, the shell syntax $x inserts the text from paramater "x" at that point, but unquoted: it will be broken into words on whitespace. Conversely "$x" inserts the text from paramater "x" at that point, but quoted: it is a single string, not multiple words. For many parameters this is enough. However, the command line arguments are effectively a list of strings. The shell offers $* for the command line arguments, but that behaves exactly like any other paramater: you get all the words broken up if upquoted, or a single string if quoted. Both are usually not correct. Because keeping script command line arguments intact is very important the variable $@ was also made. It is just like $* except for the special case when one writes "$@", in which case it will be expanded to all the arguments correctly quoted. So if you are writing a wrapper script, for example to invoke notmuch or mairix with some options and then the search terms supplied on the script command line, you might call notmuch like this: # invoke notmuch with the command line arguments, intact notmuch-search -S "$@" which will work correctly even if the script was called with However, it had a single annoying misfeature/bug: For historic reasons, "$@" evaluates to a single "" if there were no arguments at all, introducing a spurious new empty argument. Possibly the thinking was that something like "$@" should never vanish; after all "$x" will produce an single empty string if $x is empty. The ${1+} simply avoids using "$@" at all unless there are arguments, producing correct behaviour in the no-arguments case. More recent shells treat a bare unquotes $@ specially also: it produces the command line arguments correctly quoted like "$@", and also does the no-arguments case correctly. However, because my scripting dates from tling ago, I don't rely on this because some shells may not have it. hence the incantation, which is portable. The core lesson here is to pretty much never use $* (actually, there are some cases for it) and prefer "$@", but when you use "$@" to be truly paranoid and robust you should protect it from misuse with ${1+"$@"}. Cheers, Cameron Simpson
Re: How do you survive without notmuch?
On 06Apr2016 16:10, derek martinwrote: It's a little more complicated for work mail, as there is some crossover... But what I do in that case is use filters to make sure all relevant folders get a copy. I admit that's wasteful and annoying, but in the overwhelming majority of cases the messages are small enough that I don't really care about the extra copies. Me too, but because I use maildirs the copies are hard links. On the other hand, maildir is inherently more expensive in storage than mbox... But I find it more flexible. [...] Further, what if you want all messages from Billy and those messages are spread across different folders. So, this basically never happens. It's all about how you manage your mail folders. Usually when I reach for notmuch it is because I have mismanaged my folders. Hmm, that message about blah isn't there - where is it? Cheers, Cameron Simpson
Re: How do you survive without notmuch?
Hi Cameron, On Wed, Apr 06, 2016 at 09:50:28AM +1000, Cameron Simpson wrote: > Consider using ${1+"$@"}, which preserves quoting. How is this better than just "$@"? I believe it's non-portable (and for that reason I'm less familiar with that syntax) but if I understand correctly it expands like: if $1 is set use that, otherwise use "$@" (all arguments, individually quoted) It seems as though this always evaluates to $1 (since if $1 is unset, $@ is also necessarily empty)... which I think is not what is needed here. Am I mistaken? I believe just "$@" (including the quotes) is what you want here. Thanks -- Derek D. Martinhttp://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience. pgpbAVcnrRmCf.pgp Description: PGP signature
Re: How do you survive without notmuch?
On Tue, Apr 05, 2016 at 12:47:03PM -0400, Xu Wang wrote: > I am so used to using notmuch integrated into mutt (via mutt-kz), that > I would like to be able to understand how someone does *not* use > notmuch. How do you search for a certain message? Is it simply a > matter of the following? > > 1. remember which folder it is in > 2. change to that folder > 3. use mutt's search Just #2 and #3; I don't need to do #1 because my mail folders basically group messages from logical groups of senders, and (at least for my personal mail) there's never any crossover. It's a little more complicated for work mail, as there is some crossover... But what I do in that case is use filters to make sure all relevant folders get a copy. I admit that's wasteful and annoying, but in the overwhelming majority of cases the messages are small enough that I don't really care about the extra copies. $ df -h /home Filesystem Size Used Avail Use% Mounted on /dev/mapper/ubuntu-home 875G 198G 632G 24% /home Got plenty of room for more. :) > Further, what if you want all messages from Billy and those messages > are spread across different folders. So, this basically never happens. It's all about how you manage your mail folders. -- Derek D. Martinhttp://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience. pgp35FujzBO2t.pgp Description: PGP signature
Re: How do you survive without notmuch?
On Tue, Apr 5, 2016 at 7:50 PM, Cameron Simpsonwrote: > On 05Apr2016 16:28, Patrick Shanahan wrote: >> >> * Chris Green [04-05-16 14:21]: >>> >>> On Tue, Apr 05, 2016 at 12:47:03PM -0400, Xu Wang wrote: >>> > I am so used to using notmuch integrated into mutt (via mutt-kz), that >>> > I would like to be able to understand how someone does *not* use >>> > notmuch. How do you search for a certain message? Is it simply a >>> > matter of the following? >>> > >>> > 1. remember which folder it is in >>> > 2. change to that folder >>> > 3. use mutt's search > > > Like others, most of my mailboxes are closely aligned with mailing lists, so > (1) is usually (but not always) fairly easy. Unless I've deleted (move to > archive folder) the relevant messages. > >>> > Further, what if you want all messages from Billy and those messages >>> > are spread across different folders. What are steps to see all >>> > messages from Billy? >>> > >>> I just have a script that calls mairix:- >>> mairix $* > > > Consider using ${1+"$@"}, which preserves quoting. > >>> mutt -f ~/Mail/Tm/mairix > > > And making a per-search temp folder. I've got a script "notmuch-search" for > the same purpose that makes a temp folder for the result, opens mutt, > discards the folder. > > https://bitbucket.org/cameron_simpson/css/src/tip/bin/notmuch-search > > Of course, that may not be your desired workflow. > > For usability, since I open mutt via an alias named "+", eg "+ mutt" to open > the mutt folder, I have aliases "++" to invoke "notmuch-search -S > search-terms..." and "+++" to update the notmuch indices. > > So I always do this from outside mutt in an spare window. > >>> This has a big advantage over anything running in an existing mutt >>> window as I can search for something in another window then refer to >>> it while I'm composing a mail in the current mutt window. > > > Me too. > > The other tweak I have is that my mutt compose sessions are transparently > spawned into detachable tmux (or screen) sessions so if I block on a new > message I can detach from it and return the the main mutt index. I can open > the compose session in another window and proceed. Possibly weeks later :-( > > For example, right now my tmux listing includes: > > 18 mutt-06apr2016-09_41-Re__How_do_you_survive_without_notmuch_: 1 windows > (created Wed Apr 6 09:41:41 2016) [178x50] (attached) > > which is this message. > > Cheers, > Cameron Simpson Thank you everyone for your replies!!! It is good to know that alternatives are out. That is great thing about mutt community. Kind regards, Xu
Re: How do you survive without notmuch?
On 05Apr2016 16:28, Patrick Shanahanwrote: * Chris Green [04-05-16 14:21]: On Tue, Apr 05, 2016 at 12:47:03PM -0400, Xu Wang wrote: > I am so used to using notmuch integrated into mutt (via mutt-kz), that > I would like to be able to understand how someone does *not* use > notmuch. How do you search for a certain message? Is it simply a > matter of the following? > > 1. remember which folder it is in > 2. change to that folder > 3. use mutt's search Like others, most of my mailboxes are closely aligned with mailing lists, so (1) is usually (but not always) fairly easy. Unless I've deleted (move to archive folder) the relevant messages. > Further, what if you want all messages from Billy and those messages > are spread across different folders. What are steps to see all > messages from Billy? > I just have a script that calls mairix:- mairix $* Consider using ${1+"$@"}, which preserves quoting. mutt -f ~/Mail/Tm/mairix And making a per-search temp folder. I've got a script "notmuch-search" for the same purpose that makes a temp folder for the result, opens mutt, discards the folder. https://bitbucket.org/cameron_simpson/css/src/tip/bin/notmuch-search Of course, that may not be your desired workflow. For usability, since I open mutt via an alias named "+", eg "+ mutt" to open the mutt folder, I have aliases "++" to invoke "notmuch-search -S search-terms..." and "+++" to update the notmuch indices. So I always do this from outside mutt in an spare window. This has a big advantage over anything running in an existing mutt window as I can search for something in another window then refer to it while I'm composing a mail in the current mutt window. Me too. The other tweak I have is that my mutt compose sessions are transparently spawned into detachable tmux (or screen) sessions so if I block on a new message I can detach from it and return the the main mutt index. I can open the compose session in another window and proceed. Possibly weeks later :-( For example, right now my tmux listing includes: 18 mutt-06apr2016-09_41-Re__How_do_you_survive_without_notmuch_: 1 windows (created Wed Apr 6 09:41:41 2016) [178x50] (attached) which is this message. Cheers, Cameron Simpson
Re: How do you survive without notmuch?
* Chris Green[04-05-16 14:21]: > On Tue, Apr 05, 2016 at 12:47:03PM -0400, Xu Wang wrote: > > Dear list, > > > > I am so used to using notmuch integrated into mutt (via mutt-kz), that > > I would like to be able to understand how someone does *not* use > > notmuch. How do you search for a certain message? Is it simply a > > matter of the following? > > > > 1. remember which folder it is in > > 2. change to that folder > > 3. use mutt's search > > > > I don't know if it is poor memory or laziness, but that seems > > significantly more difficult than X from anywhere to search. > > > > Further, what if you want all messages from Billy and those messages > > are spread across different folders. What are steps to see all > > messages from Billy? > > > I just have a script that calls mairix:- > > #!/bin/bash > # > # > # Run mairix for a given string and run mutt on the results > # > mairix $* > mutt -f ~/Mail/Tm/mairix > > This has a big advantage over anything running in an existing mutt > window as I can search for something in another window then refer to > it while I'm composing a mail in the current mutt window. I run mairix via cron every 10 minutes and can access mairix.mbox via my mutt index screen :) -- (paka)Patrick Shanahan Plainfield, Indiana, USA @ptilopteri http://en.opensuse.orgopenSUSE Community Memberfacebook/ptilopteri http://wahoo.no-ip.orgPhoto Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535@ http://linuxcounter.net
Re: How do you survive without notmuch?
On Tue, Apr 05, 2016 at 12:47:03PM -0400, Xu Wang wrote: > > I am so used to using notmuch integrated into mutt (via mutt-kz), that > I would like to be able to understand how someone does *not* use > notmuch. How do you search for a certain message? Is it simply a > matter of the following? > > 1. remember which folder it is in > 2. change to that folder > 3. use mutt's search I organize my stuff such that I usually know where things are. If that fails, I just use grep. w
Re: How do you survive without notmuch?
On Tue, Apr 05, 2016 at 12:47:03PM -0400, Xu Wang wrote: > Dear list, > > I am so used to using notmuch integrated into mutt (via mutt-kz), that > I would like to be able to understand how someone does *not* use > notmuch. How do you search for a certain message? Is it simply a > matter of the following? > > 1. remember which folder it is in > 2. change to that folder > 3. use mutt's search > > I don't know if it is poor memory or laziness, but that seems > significantly more difficult than X from anywhere to search. > > Further, what if you want all messages from Billy and those messages > are spread across different folders. What are steps to see all > messages from Billy? > I just have a script that calls mairix:- #!/bin/bash # # # Run mairix for a given string and run mutt on the results # mairix $* mutt -f ~/Mail/Tm/mairix This has a big advantage over anything running in an existing mutt window as I can search for something in another window then refer to it while I'm composing a mail in the current mutt window. -- Chris Green
Re: How do you survive without notmuch?
On Tue, Apr 05, 2016 at 12:47:03 -0400, Xu Wang wrote: > I am so used to using notmuch integrated into mutt (via mutt-kz), that > I would like to be able to understand how someone does *not* use > notmuch. How do you search for a certain message? Is it simply a > matter of the following? I don't have it *integrated* per se, but I do have these bindings: macro index \Cn "\ set my_wait_key = \$wait_key\ unset wait_key\ notmuch-mutt --prompt search\ ~/.cache/notmuch/mutt/results\ set wait_key = \$my_wait_key\ unset my_wait_key\ " "search mail (using notmuch)" macro index "\ set my_wait_key = \$wait_key\ unset wait_key\ notmuch-mutt thread\ ~/.cache/notmuch/mutt/results\ set wait_key = \$my_wait_key\ unset my_wait_key\ " "search and reconstruct owning thread (using notmuch)" using the notmuch-mutt contrib/ script (from notmuch itself). --Ben
Re: How do you survive without notmuch?
* Xu Wang[04-05-16 12:51]: > Dear list, > > I am so used to using notmuch integrated into mutt (via mutt-kz), that > I would like to be able to understand how someone does *not* use > notmuch. How do you search for a certain message? Is it simply a > matter of the following? > > 1. remember which folder it is in > 2. change to that folder > 3. use mutt's search > > I don't know if it is poor memory or laziness, but that seems > significantly more difficult than X from anywhere to search. > > Further, what if you want all messages from Billy and those messages > are spread across different folders. What are steps to see all > messages from Billy? mbox: mairix f:billy -- (paka)Patrick Shanahan Plainfield, Indiana, USA @ptilopteri http://en.opensuse.orgopenSUSE Community Memberfacebook/ptilopteri http://wahoo.no-ip.orgPhoto Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535@ http://linuxcounter.net
How do you survive without notmuch?
Dear list, I am so used to using notmuch integrated into mutt (via mutt-kz), that I would like to be able to understand how someone does *not* use notmuch. How do you search for a certain message? Is it simply a matter of the following? 1. remember which folder it is in 2. change to that folder 3. use mutt's search I don't know if it is poor memory or laziness, but that seems significantly more difficult than X from anywhere to search. Further, what if you want all messages from Billy and those messages are spread across different folders. What are steps to see all messages from Billy? Kind regards, Xu