Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'alter': 0.09; 'arguments': 0.09; 'facts': 0.09; 'parsing': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'used.': 0.09; 'command-line': 0.16; 'enough.': 0.16; 'finney': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sudo': 0.16; 'do.': 0.18; 'trying': 0.19; 'later': 0.20; 'command': 0.22; 'example': 0.22; 'handles': 0.22; 'shell': 0.22; 'header:User-Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'tim': 0.29; 'needed.': 0.30; 'writes:': 0.31; 'figure': 0.32; 'not.': 0.33; 'there,': 0.34; 'problem': 0.35; "can't": 0.35; 'common': 0.35; 'there': 0.35; 'wishes,': 0.36; 'requirements': 0.37; 'ben': 0.38; 'checks': 0.38; 'skip:. 20': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'short': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'solve': 0.60; 'matter': 0.61; 'course': 0.61; "you've": 0.63; 'our': 0.64; 'provide': 0.64; 'determine': 0.67; 'presented': 0.69; 'examining': 0.84; 'received:125': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: Quotation Ugliness Date: Thu, 27 Nov 2014 07:24:49 +1100 References: <54756D5F.4040806@tundraware.com> <5475EAB3.7060503@tundraware.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:5FmHcFZHWYLLdjv20xdtfBWyNV8= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417033498 news.xs4all.nl 2848 [2001:888:2000:d::a6]:43597 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81608 Tim Daneliuk writes: > The problem I am trying to solve is to determine whether the user > needs to provide a sudo password or not. Again, the ‘sudo’ program itself will figure this out and ask for a password if it needs one. Examining the command line isn't enough. Even if you find a ‘sudo’ command there, there are common circumstances where no password is needed. The program handles all this, you can't predict it from outside. > Right now, the program just naively checks the arguments to see if > .startswith("sudo'). As the example given illustrates, that clearly > fails if the sudo is given later in a longer pipeline. The problem as you've presented it requires you to re-implement the command-line parsing from whatever command shell is used. You will necessarily fall short of that, no matter what you do. Your best course is to get the requirements changed, as they are currently not implementable. -- \ “Facts are stubborn things; and whatever may be our wishes, our | `\ inclinations, or the dictates of our passion, they cannot alter | _o__) the state of facts and evidence.” —John Adams, 1770-12-04 | Ben Finney