Opened 4 years ago

Closed 4 years ago

#1033 closed Bug (fixed)

archive.sh readlink -f illegal operation under FreeBSD7.1

Reported by: ogs22 Owned by:
Priority: normal Milestone: Piwik 0.5
Component: Core Keywords:
Cc: Sensitive: no

Description

in misc/cron/archive.sh line 26:

PIWIK_CRON_FOLDER=dirname $(readlink -f ${0})

Gives an error:
readlink: illegal option -- f
usage: readlink [-n] [file ...]
usage: dirname string

Testing readlink on Scientific Linux SL release 5.3

readlink -f /path/to/file

also gives an error

readlink: Need exactly one argument.
Try `readlink --help' for more information.

Attachments (2)

archive.sh (1.8 KB) - added by ogs22 4 years ago.
archive.patch (584 bytes) - added by ogs22 4 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 4 years ago by vipsoft (robocoder)

  • Milestone set to 1 - Piwik 0.5

Remove the -f and report back to us.

comment:2 Changed 4 years ago by ogs22

man readlink says:
'When invoked as readlink, only the target of the symbolic link is
printed. If the given argument is not a symbolic link, readlink will
print nothing and exit with an error.'

I've changed it to
PIWIK_CRON_FOLDER=dirname ${0}

To make my local version work

comment:3 Changed 4 years ago by vipsoft (robocoder)

Ah yes, thanks for the reminder. That's why we use -f.

comment:4 Changed 4 years ago by ogs22

act_path() {
    local pathname="$1"
    readlink -f "$pathname" 2>/dev/null || \
    realpath "$pathname" 2>/dev/null || \
    type -P "$pathname" 2>/dev/null
}

ARCHIVE=`act_path ${0}`
PIWIK_CRON_FOLDER=`dirname ${ARCHIVE}`

The above works for me on FreeBSD and Scientific Linux SL

comment:5 Changed 4 years ago by matt (mattab)

ogs22, do you think you could submit a version that works on freebsd-SL linux and on debian/other linux? it would be very useful. Thanks

comment:6 Changed 4 years ago by ogs22

Sorry yes I should have said the above code should work on any Linux version the original code worked on as it tries the readlink -f first.

I'll attach the modified archive.sh

Changed 4 years ago by ogs22

comment:7 Changed 4 years ago by matt (mattab)

ogs22, could you post a diff instead of the full file please? thx

Changed 4 years ago by ogs22

comment:8 Changed 4 years ago by vipsoft (robocoder)

  • Resolution set to fixed
  • Status changed from new to closed

In [1568], fixes #1033 - archive.sh patch; thanks ogs22

Note: See TracTickets for help on using tickets.