Re: Force "ls" to show .exe extension

2015-01-08 Thread Paul
Andrey Repin  yandex.ru> writes:
>> I don't like using the back ticks myself because of its atrocious
>> readability, but I'm not religious about it.
> 
> Then don't use them. Use "$( )" instead. Aside readability issues,
> it also solve nesting and quoting problems.

So much better...thanks, Andrey!


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Force "ls" to show .exe extension

2015-01-08 Thread Andrey Repin
Greetings, Paul!

> I don't like using the back ticks myself because of its atrocious
> readability, but I'm not religious about it.

Then don't use them. Use "$( )" instead. Aside readability issues, it also
solve nesting and quoting problems.


--
WBR,
Andrey Repin (anrdae...@yandex.ru) 08.01.2015, <21:25>

Sorry for my terrible english...


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Force "ls" to show .exe extension

2015-01-08 Thread Paul
Bob McGowan  symantec.com> writes:
| Back to Paul's problem, getting a list of the actual filenames, as
| they actually exist in the filesystem, can be handled by 'find', I
| think.  At least it worked in my simple test setup, above.
| 
| $ find . -name abc
| ./abc
| $ find . -name 'abc*'
| ./abc
| ./abc.bat
| ./abc.exe
| ./abc.sh
| 
| Since find prints each file name on a line by itself, filenames with
| spaces just "work":
| 
| $ touch 'pdq xyz'
| $ find .
| .
| ./abc
| ./abc.bat
| ./abc.exe
| ./abc.sh
| ./pdq xyz
| 
| To process the above output, use a 'while' loop with the 'read'
| command and quote the shell variable in the loop body to preserve
| the single filename with spaces:
| 
| $ find . |
| > while read filenames
| > do
| >  file "$filenames"
| > done
| .: directory
| ./abc: empty
| ./abc.bat: empty
| ./abc.exe: empty
| ./abc.sh: empty
| ./pdq xyz: empty
| 
| The above is for illustration only.  It is not efficient, since
| 'file' is run 6 times, when it could have run once with multiple
| file names, but then the quoting wouild be more difficult.  You
| would replace it with 'ls -l' to get individual file metadata,
| though again it would be inefficient.
| 
| Using 'xargs' would improve this, assuming the right parameters are
| used.  This will work with 'xargs' and 'cpio', I'm not sure which
| other commands might support literal NULL termination of strings
| (note the 0 (zero) in each command's args).
| 
| find . -print0 | xargs -0 file
| .: directory
| ./abc: empty
| ./abc.bat: empty
| ./abc.exe: empty
| ./abc.sh: empty
| ./pdq xyz: empty

It certainly is educational.  For the original problem, though, I'd
like to keep it simple enough to fit into one line.  It has to accept
output from "type" and must allow for "ls -l" and/or "ls -ltd" (or the
like):

   $ls -d `type -pa pdfcrop | sed -e 's/.*/&*/'`

  /bin/pdfcrop@  /home/User.Name/bin/pdfcrop.exe*
  /usr/bin/pdfcrop@

   $ls -ld `type -pa pdfcrop | sed -e 's/.*/&*/'`

  lrwxrwxrwx 1 User.Name Domain Users 48 Nov 10 16:35 /bin/pdfcrop
  -> /usr/share/texmf-dist/scripts/pdfcrop/pdfcrop.pl*

  -rwx--+ 1 User.Name Domain Users 33792 Jun 21 2013
  /home/User.Name/bin/pdfcrop.exe*

  lrwxrwxrwx 1 User.Name Domain Users 48 Nov 10 16:35
  /usr/bin/pdfcrop ->
  /usr/share/texmf-dist/scripts/pdfcrop/pdfcrop.pl*

I don't like using the back ticks myself because of its atrocious
readability, but I'm not religious about it.

P.S. Gotta luv the gmane captcha words.


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Force "ls" to show .exe extension

2015-01-07 Thread Bob McGowan
On 1/7/15, 8:07 AM, "Paul"  wrote:

>Buchbinder, Barry (NIH/NIAID) [E]  niaid.nih.gov> writes:
>>Paul sent the following at Tuesday, January 06, 2015 7:12 PM
>>> I'm wading through many files in two file trees. In particular, I'm
>>> looking at corresponding directories in the two trees where "diff
>>> -qr" revealed differences. I want the absolute truth of what the
>>> filename is with minimal distractions about how to achieve that.
>>> Then, I can focus on figuring how those files came about, and how
>>> the differences arose.
>> 
>> Not a Cygwin solution but the following should give real names.
>> 
>> cmd /c dir /b /a:
>> 
>> (The /a: makes sure that hidden files are listed.)
>
>That works great, Barry.  The following also works:
>
>   cmd /c dir /b /a: | dos2unix | xargs ls -ltd
>
>However, variation#1
>
>   type -pa pdfcrop | xargs cmd /c dir /b /a:
>
>doesn't work because dir expects DOS filenames (I suspect).
>
>Variation#2
>
>   type -pa pdfcrop | xargs cygpath -aw | xargs cmd /c dir /b /a:
>
>doesn't work because the backward slashes are interpretted by Escapes
>by bash.
>
>Variation#3 (on *one* line):
>
>   type -pa pdfcrop | xargs cygpath -aw -t mixed | xargs cmd /c dir /b
>   /a:
>
>doesn't work because
>
>   Parameter format not correct - "cygwin64"
>
>To find out what was going on, I stuck an "echo" in front of cmd,
>which yielded the following (on *one* line):
>
>   cmd /c dir /b /a: C:/cygwin64/home/User.Name/bin/pdfcrop
>   C:/cygwin64/usr/share/texmf-dist/scripts/pdfcrop/pdfcrop.pl
>   C:/cygwin64/usr/share/texmf-dist/scripts/pdfcrop/pdfcrop.pl
>
>I think the dir command is interpreting /cygwin64 as a command switch.

That is true.

To further add to the confusion this can cause (and a possible solution
after this):

$ ls -l
total 3
-rwxr-xr-x 1 rmcgowan None 45 Jan  6 15:12 abc.bat
-rwxr-xr-x 1 rmcgowan None 50 Jan  7 09:48 abc.exe # note this file size
-rwxr-xr-x 1 rmcgowan None 48 Jan  6 15:15 abc.sh
$ date > abc # NOTE file name...
$ l
total 3
-rwxr-xr-x 1 rmcgowan None 45 Jan  6 15:12 abc.bat
-rwxr-xr-x 1 rmcgowan None 30 Jan  7 09:48 abc.exe # And here.
-rwxr-xr-x 1 rmcgowan None 48 Jan  6 15:15 abc.sh


And trying to do a 'touch abc' changes the date associated with abc.exe
(it was Jan 6, is now Jan 7).

But 'mkdir abc' creates the directory abc.

And in an empty directory, 'touch abc' creates the empty file 'abc', and
'touch abc.exe' then creates 'abc.exe'.

And now, if you do a 'touch abc', the timestamp of the file 'abc' is
changed, and 'abc.exe' is left alone.

Back to Paul's problem, getting a list of the actual filenames, as they
actually exist in the filesystem, can be handled by 'find', I think.  At
least it worked in my simple test setup, above.

$ find . -name abc
./abc
$ find . -name 'abc*'
./abc
./abc.bat
./abc.exe
./abc.sh

Since find prints each file name on a line by itself, filenames with
spaces just "work":

$ touch 'pdq xyz'
$ find .
.
./abc
./abc.bat
./abc.exe
./abc.sh
./pdq xyz


To process the above output, use a 'while' loop with the 'read' command
and quote the shell variable in the loop body to preserve the single
filename with spaces:

$ find . |
> while read filenames
> do
>  file "$filenames"
> done
.: directory
./abc: empty
./abc.bat: empty
./abc.exe: empty
./abc.sh: empty
./pdq xyz: empty


The above is for illustration only.  It is not efficient, since 'file' is
run 6 times, when it could have run once with multiple file names, but
then the quoting wouild be more difficult.  You would replace it with 'ls
-l' to get individual file metadata, though again it would be inefficient.

Using 'xargs' would improve this, assuming the right parameters are used.
This will work with 'xargs' and 'cpio', I'm not sure which other commands
might support literal NULL termination of strings (note the 0 (zero) in
each command's args).

find . -print0 | xargs -0 file
.: directory
./abc: empty
./abc.bat: empty
./abc.exe: empty
./abc.sh: empty
./pdq xyz: empty


I hope this is helpful.

Bob


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Force "ls" to show .exe extension

2015-01-07 Thread Paul
Buchbinder, Barry (NIH/NIAID) [E]  niaid.nih.gov> writes:
>Paul sent the following at Tuesday, January 06, 2015 7:12 PM
>> I'm wading through many files in two file trees. In particular, I'm
>> looking at corresponding directories in the two trees where "diff
>> -qr" revealed differences. I want the absolute truth of what the
>> filename is with minimal distractions about how to achieve that.
>> Then, I can focus on figuring how those files came about, and how
>> the differences arose.
> 
> Not a Cygwin solution but the following should give real names.
> 
> cmd /c dir /b /a:
> 
> (The /a: makes sure that hidden files are listed.)

That works great, Barry.  The following also works:

   cmd /c dir /b /a: | dos2unix | xargs ls -ltd

However, variation#1

   type -pa pdfcrop | xargs cmd /c dir /b /a:

doesn't work because dir expects DOS filenames (I suspect).

Variation#2

   type -pa pdfcrop | xargs cygpath -aw | xargs cmd /c dir /b /a:

doesn't work because the backward slashes are interpretted by Escapes
by bash.

Variation#3 (on *one* line):

   type -pa pdfcrop | xargs cygpath -aw -t mixed | xargs cmd /c dir /b
   /a:

doesn't work because

   Parameter format not correct - "cygwin64"

To find out what was going on, I stuck an "echo" in front of cmd,
which yielded the following (on *one* line):

   cmd /c dir /b /a: C:/cygwin64/home/User.Name/bin/pdfcrop
   C:/cygwin64/usr/share/texmf-dist/scripts/pdfcrop/pdfcrop.pl
   C:/cygwin64/usr/share/texmf-dist/scripts/pdfcrop/pdfcrop.pl

I think the dir command is interpreting /cygwin64 as a command switch.


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Force "ls" to show .exe extension

2015-01-07 Thread Paul
Andrey Repin  yandex.ru> writes:
>> I'm wading through many files in two file trees.  In particular,
>> I'm looking at corresponding directories in the two trees where
>> "diff -qr" revealed differences.  I want the absolute truth of what
>> the filename is with minimal distrations about how to achieve that.
>> Then, I can focus on figuring how those files came about, and how
>> the differences arose.
> 
> Use more appropriate tools.  I.e. Far manager have standard
> file/directory comparison plugin.  Which can quickly compare paths
> and or contents of the files.  However, it will not show differences
> inside files, only show that they are different, but you can always
> augment it with view: "\$Revision.*\$" -I "\$Date.*\$" -I "\$Author.*\$" -I "\$URL.*\$"
> !?$UnixDiff$Options ((-c, -b etc.)):?! --strip-trailing-cr --
> "!#!\!.!" "!^!\!.!"
> 
> P.S.  I'm not saying that this can not be achieved with Cygwin
> tools, but even then, using "ls" to compare files one by one is
> hardly efficient.

Andrey, I appreciate the awareness that you gave of Far Manager, but
I'm going to have to say that in this case, it's not the most suitable
course of action.  We're a locked down shop, so installing new tools
is problematic.  Even if it was available, however, the prevailing
environment is that committing time to explore new tools is carefully
weighed against what else is not being done.  I realize that the
latter doesn't fly very well in an open forum in which people freely
donate their time to help, but it is a reality that can't be changed
for many.  Finally, if Far Manager were installable, whether to give
it a try would be weighed against the fact that a lot more ls is being
used in figuring how differences between file trees.  It's actually a
small part, and I was just giving a bit of context around it.

Nevertheless, as I said, I appreciate the extra awareness of that
tool.


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



RE: Force "ls" to show .exe extension

2015-01-07 Thread cyg Simple
> From:  Tom Robinson
> 
> If you don't want to specify the extension, can you specify as asterisk?
> 
> [3236 CBGSAS04:~/Documents]$ touch name.exe
> 
> [3237 CBGSAS04:~/Documents]$ ls -l name
> -rw-r--r--+ 1 cbg.tom Domain Users 0 Jan  7 09:34 name
> 
> [3238 CBGSAS04:~/Documents]$ ls -l name.exe
> -rw-r--r--+ 1 cbg.tom Domain Users 0 Jan  7 09:34 name.exe
> 

I often consider this to be broken behavior considering that I could have
both a name and name.exe file which would change the outcome of this
scenario.

--
Cyg Simple


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



RE: Force "ls" to show .exe extension

2015-01-06 Thread Buchbinder, Barry (NIH/NIAID) [E]
Paul sent the following at Tuesday, January 06, 2015 7:12 PM
>I'm wading through many files in two file trees. In particular, I'm
>looking at corresponding directories in the two trees where "diff -qr"
>revealed differences. I want the absolute truth of what the filename is
>with minimal distractions about how to achieve that. Then, I can focus
>on figuring how those files came about, and how the differences arose.

Not a Cygwin solution but the following should give real names.

cmd /c dir /b /a:

(The /a: makes sure that hidden files are listed.)

- Barry
  - Disclaimer: Statements made herein are not made on behalf of NIAID.

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Force "ls" to show .exe extension

2015-01-06 Thread Andrey Repin
Greetings, Paul!

>>> ...if I have ~/bin/pdfcrop.exe, the command "ls ~/bin/pdfcrop"
>>> shows pdfcrop rather than pdfcrop.exe.  Is there any way to force
>>> ls to show the full filename (including extension) if it matched
>>> the ls argument, even if the ls argument doesn't specify the
>>> extension?  I read
>>> http://cygwin.com/cygwin-ug-net/using-specialnames.html, which
>>> helps explain the situation, but not a solution.
>>
>> I see people are diving deep to find a "solution", but noone has
>> asked, what is the problem they are trying to solve here.  So, let
>> me ask it: what is the problem?

> Hello, Andrey,

> I'm wading through many files in two file trees.  In particular, I'm
> looking at corresponding directories in the two trees where "diff -qr"
> revealed differences.  I want the absolute truth of what the filename
> is with minimal distrations about how to achieve that.  Then, I can
> focus on figuring how those files came about, and how the differences
> arose.

Use more appropriate tools.
I.e. Far manager have standard file/directory comparison plugin.
Which can quickly compare paths and or contents of the files.
However, it will not show differences inside files, only show that they are
different, but you can always augment it with
view:

Sorry for my terrible english...


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Force "ls" to show .exe extension

2015-01-06 Thread Paul
Andrey Repin  yandex.ru> writes:
>> ...if I have ~/bin/pdfcrop.exe, the command "ls ~/bin/pdfcrop"
>> shows pdfcrop rather than pdfcrop.exe.  Is there any way to force
>> ls to show the full filename (including extension) if it matched
>> the ls argument, even if the ls argument doesn't specify the
>> extension?  I read
>> http://cygwin.com/cygwin-ug-net/using-specialnames.html, which
>> helps explain the situation, but not a solution.
>
> I see people are diving deep to find a "solution", but noone has
> asked, what is the problem they are trying to solve here.  So, let
> me ask it: what is the problem?

Hello, Andrey,

I'm wading through many files in two file trees.  In particular, I'm
looking at corresponding directories in the two trees where "diff -qr"
revealed differences.  I want the absolute truth of what the filename
is with minimal distrations about how to achieve that.  Then, I can
focus on figuring how those files came about, and how the differences
arose.


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Force "ls" to show .exe extension

2015-01-06 Thread Andrey Repin
Greetings, Paul!

> Right now, if I have ~/bin/pdfcrop.exe, the command "ls ~/bin/pdfcrop"
> shows pdfcrop rather than pdfcrop.exe.  Is there any way to force ls
> to show the full filename (including extension) if it matched the ls
> argument, even if the ls argument doesn't specify the extension?  I
> read http://cygwin.com/cygwin-ug-net/using-specialnames.html, which
> helps explain the situation, but not a solution.

I see people are diving deep to find a "solution", but noone has asked, what
is the problem they are trying to solve here.
So, let me ask it: what is the problem?


--
WBR,
Andrey Repin (anrdae...@yandex.ru) 07.01.2015, <01:31>

Sorry for my terrible english...


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Force "ls" to show .exe extension

2015-01-06 Thread Eric Blake
On 01/06/2015 02:28 PM, Paul wrote:
> Paul  gmail.com> writes:
>> Both solutions are great.  I'll set the --append-exe in my bash
>> aliases, and for systems outside of my normal working environment
>> (e.g., working with someone on their unix sessions), I know I can
>> force display of .exe using asterisk.
> 
> Drat. If I pipe files to 'xargs ls', the unaliased ls command is used:
> 
>type -pa pdfcrop | xargs ls

alias xargs='xargs '

Then the alias expansion of xargs will in turn allow alias expansion of
the next argument.  (Except that you then have to also create
trailing-space aliases for all options you commonly pass to xargs
between 'xargs' and the final command name).

Sadly, xargs is one of the cases where shell functions won't help (xargs
doesn't execute the shell function).  Your other solution is to modify
$PATH to point to a directory under your control as the first thing,
where 'cat /your/ls' contains:
#!/bin/sh
exec /bin/ls --append-exe "$@"

such that your script then gets picked up by xargs, and you no longer
have to worry about aliases.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: Force "ls" to show .exe extension

2015-01-06 Thread Paul
Paul  gmail.com> writes:
> Both solutions are great.  I'll set the --append-exe in my bash
> aliases, and for systems outside of my normal working environment
> (e.g., working with someone on their unix sessions), I know I can
> force display of .exe using asterisk.

Drat. If I pipe files to 'xargs ls', the unaliased ls command is used:

   type -pa pdfcrop | xargs ls

I can always append asterisks to each pdfcrop path using sed, or even
explicitly type --append-exe [:(] .


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Force "ls" to show .exe extension

2015-01-06 Thread Paul
Tom Robinson  gmail.com> writes:
>If you don't want to specify the extension, can you specify as
>asterisk?
>
>[3236 CBGSAS04:~/Documents]$ touch name.exe
>
>[3237 CBGSAS04:~/Documents]$ ls -l name
>-rw-r--r--+ 1 cbg.tom Domain Users 0 Jan  7 09:34 name
>
>[3238 CBGSAS04:~/Documents]$ ls -l name.exe
>-rw-r--r--+ 1 cbg.tom Domain Users 0 Jan  7 09:34 name.exe
>
>[3239 CBGSAS04:~/Documents]$ ls -l name*
>-rw-r--r--+ 1 cbg.tom Domain Users 0 Jan  7 09:34 name.exe

Yaakov Selkowitz  cygwin.com> writes:
> ls --append-exe ~/bin/pdfcrop

Tom, Yaakov,

Both solutions are great.  I'll set the --append-exe in my bash
aliases, and for systems outside of my normal working environment
(e.g., working with someone on their unix sessions), I know I can
force display of .exe using asterisk.

Thanks!


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Force "ls" to show .exe extension

2015-01-06 Thread Yaakov Selkowitz

On 2015-01-06 13:34, Paul wrote:

Right now, if I have ~/bin/pdfcrop.exe, the command "ls ~/bin/pdfcrop"
shows pdfcrop rather than pdfcrop.exe.  Is there any way to force ls
to show the full filename (including extension) if it matched the ls
argument, even if the ls argument doesn't specify the extension?  I
read http://cygwin.com/cygwin-ug-net/using-specialnames.html, which
helps explain the situation, but not a solution.


ls --append-exe ~/bin/pdfcrop

--
Yaakov


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Force "ls" to show .exe extension

2015-01-06 Thread Tom Robinson
If you don't want to specify the extension, can you specify as asterisk?

[3236 CBGSAS04:~/Documents]$ touch name.exe

[3237 CBGSAS04:~/Documents]$ ls -l name
-rw-r--r--+ 1 cbg.tom Domain Users 0 Jan  7 09:34 name

[3238 CBGSAS04:~/Documents]$ ls -l name.exe
-rw-r--r--+ 1 cbg.tom Domain Users 0 Jan  7 09:34 name.exe

[3239 CBGSAS04:~/Documents]$ ls -l name*
-rw-r--r--+ 1 cbg.tom Domain Users 0 Jan  7 09:34 name.exe


> On 2015-01-07, at 08:34, Paul  wrote:
> 
> Right now, if I have ~/bin/pdfcrop.exe, the command "ls ~/bin/pdfcrop"
> shows pdfcrop rather than pdfcrop.exe.  Is there any way to force ls
> to show the full filename (including extension) if it matched the ls
> argument, even if the ls argument doesn't specify the extension?  I
> read http://cygwin.com/cygwin-ug-net/using-specialnames.html, which
> helps explain the situation, but not a solution.


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple