Be alert for non standard base representations

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the data category.

Last Updated: 2024-11-21

In an SFTP folder accessed with a shaky PHP library, I ran stat on a file and got the following

<?php

$s->sftp->stat("./out/test")

=> [
     "size" => 0,
     "permissions" => 16895,
     "mode" => 16895,
     "type" => 2,
     "atime" => 1594293715,
     "mtime" => 1594293715,
   ]

Normally I expect permissions, which are octal 0-7, to not have 8's and 9's within them.

After searching online, I figured I had to convert the representation shown above into octal with:

printf "%o\n" 16895

giving 40777, i.e. valid permissions in the way I normally look at things.

Lesson

Be open to data being given to you in a non-standard base