# Shorthand variable for latest quarterly ports tree



## nickednamed (Aug 20, 2017)

Hi all,

Does anyone know if there is a shorthand form I can use in scripts to fetch the latest quarterly ports tree using svn?

For packages, EG in /etc/pkg/FreeBSD.conf, there is this:

```
url: "pkg+http://pkg.FreeBSD.org/${ABI}/quarterly
```
Which always downloads packages from the newest / latest quarterly repo.

However, if I wanted to write a script that will automagicaly update my ports tree to whatever the latest quarterly ports tree is, what can I use?

The latest quarterly ports tree is:

```
https://svn.freebsd.org/ports/branches/2017Q3/
```
But should I want to run the script 6 months from now (using this address), it would download the wrong tree.

So does anyone know a smarter way to do it?


----------



## Beastie (Aug 20, 2017)

Can't you just generate the current quarter dynamically in your script?

```
#!/bin/sh

QUARTER=$(date +%Y)Q$((($(date +%-m)-1)/3+1))

echo https://svn.freebsd.org/ports/branches/$QUARTER/
```
Or am I missing something here?!


----------



## nickednamed (Aug 20, 2017)

Beastie said:


> Can't you just generate the current quarter dynamically in your script?
> 
> ```
> #!/bin/sh
> ...



I'm shamefully bad at shell scripting, I couldn't get it quite right :/

EDIT: Glad you did though. Thank you.


----------



## Beastie (Aug 20, 2017)

Actually that was in part shamelessly ripped from Stack Exchange


----------

