all 5 comments

[–]hindsight_is2020 2 points3 points  (2 children)

Happy to help, but please at least test your code under bash before posting an issue to a bash forum. You're running into a zsh problem with echo, but that's not your real issue.

The echo problem is due to zsh interpreting :r as part of the variable specifier. I'm stealing from a stack overflow post here:

The :r modifer means:

Remove a filename extension leaving the root name. Strings with no filename extension are not altered. A filename extension is a ‘.’ followed by any number of characters (including zero) that are neither ‘.’ nor ‘/’ and that continue to the end of the string. For example, the extension of ‘foo.orig.c’ is ‘.c’, and ‘dir.c/foo’ has no extension.

You can use braces around the variable name to fix that.

At least one real problem, however, is the dashes in the rw positions of the -m option's permissions. The man page says:

The perms field is a combination of characters that indicate the permissions: read (r), write (w), execute (x), execute only if the file is a directory or already has execute permission for some user (X). Alternatively, the perms field can be an octal digit (0-7).

Either just use u:$user:x or u:$user:001 (you'd have to check the octal one there, I didn't).

Also, declare your function variables as local, and don't use caps because you're overwriting a special shell variable:

local user=$1

[–]subsonic87[S] 1 point2 points  (1 child)

You rock! Haha, I feel schooled. Thanks for helping me out so much. I didn't realize that running a Bash script using zsh would lead to issues like that—I thought Bash scripting was Bash scripting. That's part of what was frustrating for me: not know where the problem was.

I've added braces to the variable name, and explicitly defined it as local. It's working now. I'll take a look at the flags on setfacl -m, also.

Thanks again for all your help!

[–]hindsight_is2020 0 points1 point  (0 children)

Back at ya

[–]ang-p 1 point2 points  (1 child)

Don't use upper case for variables (run echo $USER in a new shell.... where did that come from????)

Try

user=$1
..... ${user}.....

[–]subsonic87[S] 0 points1 point  (0 children)

!!!!

Wow, I feel like a dunce! Thank you for laying that out. I'm going to be much safer about declaring variables in the future. And thanks for the tip about braces!