
    e                         S SK r S SKrS SKrS SKrS SKrS SKr \  \R                  S    S:  a  \
4rO\\
4rS rSS jrS rSS jrSS jrg! \ a    \R                  r NEf = f)	    N   c                 
   [         R                  R                  U 5      n[         R                  R                  U5      (       d  g[         R                  " U5      R
                  n[        R                  R                  S5      (       aW  [         R                  " 5       S:X  a>  [        U[        R                  [        R                  -  [        R                  -  -  5      $ [         R                  " U[         R                  5      $ )zChecks that path is an executable regular file, or a symlink towards one.

This is roughly ``os.path isfile(path) and os.access(path, os.X_OK)``.
Fsunosr   )ospathrealpathisfilestatst_modesysplatform
startswithgetuidboolS_IXUSRS_IXGRPS_IXOTHaccessX_OK)r   fpathmodes      //usr/lib/python3/dist-packages/pexpect/utils.pyis_executable_filer      s     GGT"E77>>%  775>!!D((		q  DDLL LL) LL) * + 	+ 99UBGG$$    c                    [         R                  R                  U 5      S:w  a  [        U 5      (       a  U $ Uc  [         R                  nUR                  S5      nU(       d  [         R                  nUR                  [         R                  5      nU H6  n[         R                  R                  X@5      n[        U5      (       d  M4  Us  $    g)zThis takes a given filename; tries to find it in the environment path;
then checks if it is executable. This returns the full path to the filename
if found and executable. Otherwise this returns None. NPATH)
r   r   dirnamer   environgetdefpathsplitpathsepjoin)filenameenvppathlistr   ffs         r   whichr*   0   s     
wwx B&+=h+G+G
{jjAJJwwrzz"HWW\\$)b!!I  r   c                    / nSnSnSnSnSnSnUnU  H  n	X:X  d  X:X  aY  U	S:X  a  UnM  U	S:X  a  UnM!  U	S	:X  a  UnM+  U	R                  5       (       a  X:X  a  MG  UR                  U5        SnUnM^  X)-   nUnMf  X:X  a  X)-   nUnMs  X:X  a  U	S:X  a  UnM  X)-   nM  X:X  d  M  U	S	:X  a  UnM  X)-   nM     US:w  a  UR                  U5        U$ )
a
  This splits a command line into a list of arguments. It splits arguments
on spaces, but handles embedded quotes, doublequotes, and escaped
characters. It's impossible to do this with a regular expression, so I
wrote a little state machine to parse the command line. r   r         r      \'")isspaceappend)
command_linearg_listargstate_basic	state_escstate_singlequotestate_doublequotestate_whitespacestatecs
             r   split_command_liner>   E   s     H
C KIE5#<Dy!d)d),OOC(C,Eg#'CE'Dy#g'Dy#gG J byOr   c                 R   Ub  [         R                   " 5       U-   n  [        R                  " XX#5      $ ! [         ae    [        R                  " 5       S   nUR
                  S   [        R                  :X  a*  Ub%  W[         R                   " 5       -
  nUS:  a  / / / 4s $  Oe f = fM  )zThis is a wrapper around select.select() that ignores signals. If
select.select raises a select.error exception and errno is an EINTR
error then it is ignored. Mainly this is used to ignore sigwinch
(terminal resize). r,   r   )timeselectInterruptedErrorr   exc_infoargserrnoEINTR)iwtdowtdewtdtimeoutend_timeerrs         r   select_ignore_interruptsrM      s     99;(
	==T;; 	,,.#Cxx{ekk) &&4G{!2rl* 	 s   5 A)B$"B$c                 p   Ub  [         R                   " 5       U-   n[        R                  " 5       nU  HV  nUR                  U[        R                  [        R
                  -  [        R                  -  [        R                  -  5        MX       Uc  SOUS-  nUR                  U5      nU VVs/ s H  u  pxUPM	     snn$ s  snnf ! [         ab    [        R                  " 5       S   n	U	R                  S   [        R                  :X  a'  Ub"  W[         R                   " 5       -
  nUS:  a  / s $  Oe f = fM  )zKSimple wrapper around poll to register file descriptors and
ignore signals.Ni  r,   r   )r@   rA   pollregisterPOLLINPOLLPRIPOLLHUPPOLLERRrB   r   rC   rD   rE   rF   )
fdsrJ   rK   pollerfd
timeout_msresultsafd_rL   s
             r   poll_ignore_interruptsr\      s     99;([[]FFMMFNN:V^^Kfnn\]  	!(gnJkk*-G&-.gFCCg... 	,,.#Cxx{ekk) &&4G{!	 	 s%    C /C=C C A&D31D3)N)r   r   r
   rA   r@   rE   rB   	NameErrorerrorversion_infostrstring_typesunicoder   r*   r>   rM   r\    r   r   <module>rd      sz    	 
    $
 A!6LS>L%8*:z:k  $||$s   A A"!A"