Bug 204562 - sort behaves differently: cron vs. bash
sort behaves differently: cron vs. bash
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: vixie-cron (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Marcela Mašláňová
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-29 20:18 EDT by W. Michael Petullo
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-08-31 03:16:06 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description W. Michael Petullo 2006-08-29 20:18:41 EDT
Description of problem:
/bin/sort uses the LC_ALL environment variable to determine how to sort.  There
seems to be a discrepency between how this variable is set in a user shell and
cron's environment.  This causes scripts to behave differently when run in a
user shell vs. cron.

Version-Release number of selected component (if applicable):
vixie-cron-4.1-55.FC5

How reproducible:
Every time

Steps to Reproduce:
1. Place the following script in /etc/cron.hourly:

#!/bin/sh

sort << EOF > /tmp/1
a
ab
a-
a-b
a-a

2.  Execute the script manually from a user shell and inspect /tmp/1.
3.  Wait for cron to run the script and inspect /tmp/1.
  
Actual results:
cron:
a
a-
a-a
a-b *
ab  *

user shell:
a
a-
a-a
ab  *
a-b *

Expected results:
The results should be the same whether the script is run by cron or from a user
shell.  Although one could manually set LC_ALL in the script, this requirement
is not intuitive.  From experience, coming to the proper conclusions while
debugging an issue caused by this discrepency is quite difficult!

Additional info:
I am not sure if this should be fixed in cron or elsewhere.
Comment 1 Marcela Mašláňová 2006-08-30 03:13:32 EDT
Hello,
cron set locale to system defaults or to that specified by any LC_* variable. 
Bash tracks the value of LC_ALL; used to override values for other locale 
categories. So it could work the same in my case, but it didn't. I'll look at 
it.
Comment 2 Marcela Mašláňová 2006-08-31 03:16:06 EDT
I close it as not a bug.
Shell hasn't reason for using LC_* variables for sorting if you don't use 
locales. It isn't definitely problem of cron.

Note You need to log in before you can comment on or make changes to this bug.