You are not logged in.

#1 2016-11-29 16:58:42

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,910

[SOLVED]is this a useless use of cat ?

In pkgver() of some of my git packages i have this command :

$ echo $(cat VERSION | tr "-" "_").$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
13.1.0_devel.86987.7a8def8
$

Does this qualify as an UUOC and if so what should i use instead ?

Last edited by Lone_Wolf (2016-11-29 18:05:24)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#2 2016-11-29 17:02:38

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,539

Re: [SOLVED]is this a useless use of cat ?

Yes, I would say that qualifies, but is not as bad as some. Better solution would be 'tr "-" "_" < VERSION'

Offline

#3 2016-11-29 17:14:14

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [SOLVED]is this a useless use of cat ?

Or

sed 's/-/_/' VERSION

But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#4 2016-11-29 17:28:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,514
Website

Re: [SOLVED]is this a useless use of cat ?

Or, if you want to avoid using any additional programs or spawning any additional processes (for this part):

   read _ver <VERSION
   echo ${_ver/-/_}.$(git ...

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2016-11-29 17:29:59

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED]is this a useless use of cat ?

Or,

git describe --tags| sed 's/-/./g'

Offline

#6 2016-11-29 17:31:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,514
Website

Re: [SOLVED]is this a useless use of cat ?

qinohe, that assumes there is a tag that matches the contents of the VERSION file.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2016-11-29 17:34:09

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED]is this a useless use of cat ?

Your right, they all should wink

Offline

#8 2016-11-29 18:04:44

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,910

Re: [SOLVED]is this a useless use of cat ?

Although this project appears to be using tags, git describe can only find a 6 weeks old one.
The contents of VERSION are much clearer.

I'm going with read as described by trilby.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#9 2016-11-29 18:15:52

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED]is this a useless use of cat ?

Sometimes, git describe simply doesn't work, noway, nohow. Take a look at e.g. qbittorrent-git (which I co-maintain)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB